GstBtToneConversion

GstBtToneConversion — helper class for tone unit conversion

Synopsis

struct              GstBtToneConversion;
enum                GstBtToneConversionTuning;
GstBtToneConversion * gstbt_tone_conversion_new         (GstBtToneConversionTuning tuning);
gdouble             gstbt_tone_conversion_translate_from_string
                                                        (GstBtToneConversion *self,
                                                         gchar *note);
gdouble             gstbt_tone_conversion_translate_from_number
                                                        (GstBtToneConversion *self,
                                                         guint note);
guint               gstbt_tone_conversion_note_string_2_number
                                                        (const gchar *note);
const gchar *       gstbt_tone_conversion_note_number_2_string
                                                        (guint note);
guint               gstbt_tone_conversion_note_number_offset
                                                        (guint note,
                                                         guint semitones);

Object Hierarchy

  GObject
   +----GstBtToneConversion

Properties

  "tuning"                   GstBtToneConversionTuning  : Read / Write

Description

An instance of this class can translate a musical note to a frequency, while taking a specific tuning into account. It also provides conversion betwen notes as numbers and strings.

Details

struct GstBtToneConversion

struct GstBtToneConversion;

Opaque object instance.


enum GstBtToneConversionTuning

typedef enum {
  GSTBT_TONE_CONVERSION_EQUAL_TEMPERAMENT=0,
  GSTBT_TONE_CONVERSION_JUST_INTONATION,
  GSTBT_TONE_CONVERSION_PYTHAGOREAN_TUNING,
  /* TODO(ensonic): add more tunings
   * PYTHAGOREAN_TUNING
   * MEANTONE_TEMPERAMENT
   * WELL_TEMPERAMENT
   * SYNTONIC_TEMPERAMENT
   * has variants for the tempered perfect fifth (P5):
   * - EQUAL_TEMPERAMENT  P5 is 700 cents wide
   * - 1/4 COMMA_MEANTONE P5 is 696.6 cents wide
   * - PYTHAGOREAN_TUNING P5 is 702 cents wide
   * - 5-equal            P5 is 720 cents wide
   * - 7-equal            P5 is 686 cents wide
   *
   * diatonic-scale : only white keys (C-Dur, A-Moll)
   * chromatic-scale: all 12 semitones
   * major-scale    : Dur
   * minor-scale    : Moll
   *
   * there are also tonal systems using 19, 24 and 31 keys per octave
   */
   GSTBT_TONE_CONVERSION_COUNT
} GstBtToneConversionTuning;

Supported tuning types. see http://en.wikipedia.org/wiki/Musical_tuning

GSTBT_TONE_CONVERSION_EQUAL_TEMPERAMENT

12 tones with equal distance

GSTBT_TONE_CONVERSION_JUST_INTONATION

12 tones with just intonation

GSTBT_TONE_CONVERSION_PYTHAGOREAN_TUNING

12 tones with pythagorean tuning

GSTBT_TONE_CONVERSION_COUNT

number of tunings

gstbt_tone_conversion_new ()

GstBtToneConversion * gstbt_tone_conversion_new         (GstBtToneConversionTuning tuning);

Create a new instance of a note to frequency translator, that will use the given tuning.

tuning :

the GstBtToneConversionTuning to use

Returns :

a new GstBtToneConversion translator

gstbt_tone_conversion_translate_from_string ()

gdouble             gstbt_tone_conversion_translate_from_string
                                                        (GstBtToneConversion *self,
                                                         gchar *note);

Converts the string representation of a musical note such as 'C-3' or 'd#4' to a frequency in Hz.

self :

a GstBtToneConversion

note :

a musical note in string representation

Returns :

the frequency of the note or 0.0 in case of an error

gstbt_tone_conversion_translate_from_number ()

gdouble             gstbt_tone_conversion_translate_from_number
                                                        (GstBtToneConversion *self,
                                                         guint note);

Converts the musical note number to a frequency in Hz.

self :

a GstBtToneConversion

note :

a musical note (GstBtNote)

Returns :

the frequency of the note or 0.0 in case of an error

gstbt_tone_conversion_note_string_2_number ()

guint               gstbt_tone_conversion_note_string_2_number
                                                        (const gchar *note);

Converts the string representation of a musical note such as 'C-3' or 'd#4' to a note number.

note :

a musical note in string representation

Returns :

the note number or 0 in case of an error.

gstbt_tone_conversion_note_number_2_string ()

const gchar *       gstbt_tone_conversion_note_number_2_string
                                                        (guint note);

Converts the numerical number of a note to a string. A value of 1 for note represents 'c-0'. The highest supported value is 'b-9' (or 'h-9') which is 1+(9*16)+11 (1 octave has 12 tones, 4 are left unused for easy coding).

note :

a musical note as number

Returns :

the note as string or an empty string in the case of an error.

gstbt_tone_conversion_note_number_offset ()

guint               gstbt_tone_conversion_note_number_offset
                                                        (guint note,
                                                         guint semitones);

Adds the given semitone offset to the given note number.

note :

a musical note as number

semitones :

the semitone offset

Returns :

the note plus a semitone offset

Property Details

The "tuning" property

  "tuning"                   GstBtToneConversionTuning  : Read / Write

selection frequency tuning table.

Default value: GSTBT_TONE_CONVERSION_EQUAL_TEMPERAMENT