00001
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef CSHELLSYNTH_KEY_H
00061 #define CSHELLSYNTH_KEY_H 1
00062
00063 #include <jack/jack.h>
00064 #include <cshellsynth/atomic-types.h>
00065 #include <cshellsynth/jclient.h>
00066
00070 typedef struct cs_key_tuning_struct {
00071 size_t tuning_length;
00072 const double *tuning;
00073 } cs_key_tuning_t;
00074
00082 typedef struct cs_key_struct {
00083 jack_client_t *client;
00084 jack_port_t *note_port;
00085 atomic_float_t note;
00086 jack_port_t *root_port;
00087 atomic_float_t root;
00088 jack_port_t *freq_port;
00089 atomic_ptr_t tuning;
00090 atomic_t tuning_sync;
00091 } cs_key_t;
00092
00098 int cs_key_destroy(cs_key_t *cs_key);
00099
00105 int cs_key_init(cs_key_t *self, const char *client_name, jack_options_t flags, char *server_name);
00106
00116 void cs_key_set_root(cs_key_t *self, float root);
00117
00129 int cs_key_set_tuning(cs_key_t *self, const double *tuning, size_t tuning_length);
00130
00136 float cs_key_note2freq(cs_key_t *self, float note);
00137
00141 void cs_key_set_note(cs_key_t *self, float note);
00142
00148 #define CS_A 220.0
00149
00155 #define CS_A_SHARP 233.081880759045
00156
00162 #define CS_B_FLAT 233.081880759045
00163
00169 #define CS_B 246.941650628062
00170
00176 #define CS_C_FLAT 246.941650628062
00177
00183 #define CS_C 261.625565300599
00184
00190 #define CS_B_SHARP 261.625565300599
00191
00197 #define CS_C_SHARP 277.182630976872
00198
00204 #define CS_D_FLAT 277.182630976872
00205
00211 #define CS_D 293.664767917408
00212
00218 #define CS_D_SHARP 311.126983722081
00219
00225 #define CS_E_FLAT 311.126983722081
00226
00232 #define CS_E 329.62755691287
00233
00239 #define CS_F_FLAT 329.62755691287
00240
00246 #define CS_F 349.228231433004
00247
00253 #define CS_E_SHARP 349.228231433004
00254
00260 #define CS_F_SHARP 369.994422711634
00261
00267 #define CS_G_FLAT 369.994422711634
00268
00274 #define CS_G 391.995435981749
00275
00281 #define CS_G_SHARP 415.304697579945
00282
00288 #define CS_A_FLAT 415.304697579945
00289
00295 extern const double CS_MAJOR_TUNING[];
00299 #define CS_MAJOR_TUNING_LENGTH 7
00300
00306 extern const double CS_MINOR_TUNING[];
00310 #define CS_MINOR_TUNING_LENGTH 7
00311
00317 extern const double CS_PYTHAGOREAN_TUNING[];
00321 #define CS_PYTHAGOREAN_TUNING_LENGTH 12
00322
00328 #define CS_EQUAL_TUNING ((double *) -1)
00329
00332 #define CS_EQUAL_TUNING_LENGTH 12
00333
00334 #endif