#include <jack/jack.h>#include <cshellsynth/atomic-types.h>#include <cshellsynth/jclient.h>Go to the source code of this file.
Data Structures | |
| struct | cs_key_tuning_t |
| struct | cs_key_t |
Defines | |
| #define | CS_A 220.0 |
| #define | CS_A_SHARP 233.081880759045 |
| #define | CS_B_FLAT 233.081880759045 |
| #define | CS_B 246.941650628062 |
| #define | CS_C_FLAT 246.941650628062 |
| #define | CS_C 261.625565300599 |
| #define | CS_B_SHARP 261.625565300599 |
| #define | CS_C_SHARP 277.182630976872 |
| #define | CS_D_FLAT 277.182630976872 |
| #define | CS_D 293.664767917408 |
| #define | CS_D_SHARP 311.126983722081 |
| #define | CS_E_FLAT 311.126983722081 |
| #define | CS_E 329.62755691287 |
| #define | CS_F_FLAT 329.62755691287 |
| #define | CS_F 349.228231433004 |
| #define | CS_E_SHARP 349.228231433004 |
| #define | CS_F_SHARP 369.994422711634 |
| #define | CS_G_FLAT 369.994422711634 |
| #define | CS_G 391.995435981749 |
| #define | CS_G_SHARP 415.304697579945 |
| #define | CS_A_FLAT 415.304697579945 |
| #define | CS_MAJOR_TUNING_LENGTH 7 |
| #define | CS_MINOR_TUNING_LENGTH 7 |
| #define | CS_PYTHAGOREAN_TUNING_LENGTH 12 |
| #define | CS_EQUAL_TUNING ((double *) -1) |
| #define | CS_EQUAL_TUNING_LENGTH 12 |
Functions | |
| int | cs_key_destroy (cs_key_t *cs_key) |
| int | cs_key_init (cs_key_t *self, const char *client_name, jack_options_t flags, char *server_name) |
| void | cs_key_set_root (cs_key_t *self, float root) |
| int | cs_key_set_tuning (cs_key_t *self, const double *tuning, size_t tuning_length) |
| float | cs_key_note2freq (cs_key_t *self, float note) |
| void | cs_key_set_note (cs_key_t *self, float note) |
Variables | |
| const double | CS_MAJOR_TUNING [] |
| const double | CS_MINOR_TUNING [] |
| const double | CS_PYTHAGOREAN_TUNING [] |
Key
Ruby version: Key
Key translates notes into frequencies, scaled by the sample frequency.
It does so according to an array which corresponds to the scale:
n/l
rt[n % l] * 2
where r is the root, t is the tuning array, n is the note, and l is the length of the array. Note that n / l is truncated integer arithmetic, such that n / l is the integer amount, n % l the remainder.
Additionally, notes may be fractional. Fractional notes correspond to the equation:
f
p(n/p)
where p is the previous note, n is the next note, and f is the fractional portion.
Note that in the case of equal temperament, this all just reduces to:
n r*2
Key comes with a number of pre-defined scales. Minor, Major, Equal-Tempered, and Pythagorean. If you wish to define your own, pass an array of fractional values between 1 and 2 that correspond to the notes in your scale. If you have a favorite somewhat conventional scale that you think should be predefined, file a bug or send an email with the fractional coefficients of each note, and I'll probably add it.
| #define CS_A 220.0 |
A
Ruby version: Key::A
| #define CS_A_FLAT 415.304697579945 |
Ab
Ruby version: Key::A_Flat
| #define CS_A_SHARP 233.081880759045 |
A#
Ruby version: Key::A_Sharp
| #define CS_B 246.941650628062 |
B
Ruby version: Key::B
| #define CS_B_FLAT 233.081880759045 |
Bb
Ruby version: Key::B_Flat
| #define CS_B_SHARP 261.625565300599 |
B#
Ruby version: Key::B_Sharp
| #define CS_C 261.625565300599 |
C
Ruby version: Key::C
| #define CS_C_FLAT 246.941650628062 |
Cb
Ruby version: Key::C_Flat
| #define CS_C_SHARP 277.182630976872 |
C#
Ruby version: Key::C_Sharp
| #define CS_D 293.664767917408 |
D
Ruby version: Key::D
| #define CS_D_FLAT 277.182630976872 |
Db
Ruby version: Key::D_Flat
| #define CS_D_SHARP 311.126983722081 |
D#
Ruby version: Key::D_Sharp
| #define CS_E 329.62755691287 |
E
Ruby version: Key::E
| #define CS_E_FLAT 311.126983722081 |
Eb
Ruby version: Key::E_Flat
| #define CS_E_SHARP 349.228231433004 |
E#
Ruby version: Key::E_Sharp
| #define CS_EQUAL_TUNING ((double *) -1) |
Equal temperament
Ruby version: Key::Equal
| #define CS_EQUAL_TUNING_LENGTH 12 |
Equal temperament length
| #define CS_F 349.228231433004 |
F
Ruby version: Key::F
| #define CS_F_FLAT 329.62755691287 |
Fb
Ruby version: Key::F_Flat
| #define CS_F_SHARP 369.994422711634 |
F#
Ruby version: Key::F_Sharp
| #define CS_G 391.995435981749 |
G
Ruby version: Key::G
| #define CS_G_FLAT 369.994422711634 |
Gb
Ruby version: Key::G_Flat
| #define CS_G_SHARP 415.304697579945 |
G#
Ruby version: Key::G_Sharp
| #define CS_MAJOR_TUNING_LENGTH 7 |
Major tuning length
| #define CS_MINOR_TUNING_LENGTH 7 |
Minor tuning length
| #define CS_PYTHAGOREAN_TUNING_LENGTH 12 |
Pythagorean tuning length
| int cs_key_destroy | ( | cs_key_t * | cs_key | ) |
Destroy key
See jclient_destroy
| int cs_key_init | ( | cs_key_t * | self, | |
| const char * | client_name, | |||
| jack_options_t | flags, | |||
| char * | server_name | |||
| ) |
Initialize key
| float cs_key_note2freq | ( | cs_key_t * | self, | |
| float | note | |||
| ) |
Transform a note into a frequency according to the semantics of this particular key.
Ruby version: note2freq
| void cs_key_set_note | ( | cs_key_t * | self, | |
| float | note | |||
| ) |
Set note
| void cs_key_set_root | ( | cs_key_t * | self, | |
| float | root | |||
| ) |
Set root
Ruby version: root=
| root | the frequency when note is zero. If <= 1, as a fraction of sample rate; otherwise the conventional frequency in Hz. |
| int cs_key_set_tuning | ( | cs_key_t * | self, | |
| const double * | tuning, | |||
| size_t | tuning_length | |||
| ) |
Set tuning
Ruby version: tuning=
| tuning | the tuning array. A copy is made for internal use and the variable passed is not referenced after return, unless using one of the predefined values. | |
| tuning_length | the length of the tuning array. It is possibly useful to pass less than the actual length, to drop the additional notes off the end of the scale. |
| const double CS_MAJOR_TUNING[] |
Major tuning
Ruby version: Key::Major
| const double CS_MINOR_TUNING[] |
Minor tuning
Ruby version: Key::Minor
| const double CS_PYTHAGOREAN_TUNING[] |
Pythagorean tuning
Ruby version: Key::Pythagorean
1.6.3