BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bsenote.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __BSE_NOTE_H__
00003 #define __BSE_NOTE_H__
00004 
00005 #include        <bse/bseglobals.hh>
00006 #include        <bse/bsetype.hh>
00007 
00008 G_BEGIN_DECLS
00009 
00010 /* --- import Sfi macros --- */
00011 #define BSE_MIN_NOTE            SFI_MIN_NOTE
00012 #define BSE_MAX_NOTE            SFI_MAX_NOTE
00013 #define BSE_KAMMER_NOTE         SFI_KAMMER_NOTE
00014 #define BSE_NOTE_VOID           SFI_NOTE_VOID
00015 #define BSE_NOTE_UNPARSABLE     SFI_NOTE_VOID
00016 #define BSE_NOTE_CLAMP          SFI_NOTE_CLAMP
00017 #define BSE_NOTE_IS_VALID       SFI_NOTE_IS_VALID
00018 #define BSE_NOTE_MAKE_VALID     SFI_NOTE_MAKE_VALID
00019 #define BSE_KAMMER_OCTAVE       SFI_KAMMER_OCTAVE
00020 #define BSE_MIN_OCTAVE          SFI_MIN_OCTAVE
00021 #define BSE_MAX_OCTAVE          SFI_MAX_OCTAVE
00022 #define bse_note_from_string    sfi_note_from_string
00023 #define bse_note_to_string      sfi_note_to_string
00024 #define bse_note_examine        sfi_note_examine
00025 
00026 
00027 /* --- construct notes --- */
00028 #define BSE_NOTE_OCTAVE(n)              SFI_NOTE_OCTAVE (n)
00029 #define BSE_NOTE_SEMITONE(n)            SFI_NOTE_SEMITONE (n)
00030 #define BSE_NOTE_GENERIC(o,ht_i)        SFI_NOTE_GENERIC (o, ht_i)
00031 #define BSE_NOTE_C(o)                   (BSE_NOTE_GENERIC ((o), 0))
00032 #define BSE_NOTE_Cis(o)                 (BSE_NOTE_GENERIC ((o), 1))
00033 #define BSE_NOTE_Des(o)                 (BSE_NOTE_Cis (o))
00034 #define BSE_NOTE_D(o)                   (BSE_NOTE_GENERIC ((o), 2))
00035 #define BSE_NOTE_Dis(o)                 (BSE_NOTE_GENERIC ((o), 3))
00036 #define BSE_NOTE_Es(o)                  (BSE_NOTE_Dis (o))
00037 #define BSE_NOTE_E(o)                   (BSE_NOTE_GENERIC ((o), 4))
00038 #define BSE_NOTE_F(o)                   (BSE_NOTE_GENERIC ((o), 5))
00039 #define BSE_NOTE_Fis(o)                 (BSE_NOTE_GENERIC ((o), 6))
00040 #define BSE_NOTE_Ges(o)                 (BSE_NOTE_Fis (o))
00041 #define BSE_NOTE_G(o)                   (BSE_NOTE_GENERIC ((o), 7))
00042 #define BSE_NOTE_Gis(o)                 (BSE_NOTE_GENERIC ((o), 8))
00043 #define BSE_NOTE_As(o)                  (BSE_NOTE_Gis (o))
00044 #define BSE_NOTE_A(o)                   (BSE_NOTE_GENERIC ((o), 9))
00045 #define BSE_NOTE_Ais(o)                 (BSE_NOTE_GENERIC ((o), 10))
00046 #define BSE_NOTE_Bes(o)                 (BSE_NOTE_Ais (o))
00047 #define BSE_NOTE_B(o)                   (BSE_NOTE_GENERIC ((o), 11))
00048 #define BSE_NOTE_SHIFT(n,ht_i)          SFI_NOTE_SHIFT (n, ht_i)
00049 #define BSE_NOTE_OCTAVE_UP(n)           (BSE_NOTE_SHIFT ((n), +12))
00050 #define BSE_NOTE_OCTAVE_DOWN(n)         (BSE_NOTE_SHIFT ((n), -12))
00051 
00052 
00053 /* --- functions --- */
00054 int             bse_note_from_freq                      (BseMusicalTuningType   musical_tuning,
00055                                                          double                 freq);
00056 int             bse_note_from_freq_bounded              (BseMusicalTuningType   musical_tuning,
00057                                                          double                 freq);
00058 int             bse_note_fine_tune_from_note_freq       (BseMusicalTuningType   musical_tuning,
00059                                                          int                    note,
00060                                                          double                 freq);
00061 double          bse_note_to_freq                        (BseMusicalTuningType   musical_tuning,
00062                                                          int                    note);
00063 double          bse_note_to_tuned_freq                  (BseMusicalTuningType   musical_tuning,
00064                                                          int                    note,
00065                                                          int                    fine_tune);
00066 
00067 
00068 /* --- freq array --- */
00069 typedef struct BseFreqArray BseFreqArray;
00070 BseFreqArray*   bse_freq_array_new              (guint           prealloc);
00071 void            bse_freq_array_free             (BseFreqArray   *farray);
00072 guint           bse_freq_array_n_values         (BseFreqArray   *farray);
00073 gdouble         bse_freq_array_get              (BseFreqArray   *farray,
00074                                                  guint           index);
00075 void            bse_freq_array_insert           (BseFreqArray   *farray,
00076                                                  guint           index,
00077                                                  gdouble         value);
00078 void            bse_freq_array_append           (BseFreqArray   *farray,
00079                                                  gdouble         value);
00080 #define         bse_freq_array_prepend(a,v)      bse_freq_array_insert ((a), 0, (v))
00081 void            bse_freq_array_set              (BseFreqArray   *farray,
00082                                                  guint           index,
00083                                                  gdouble         value);
00084 /* find match_freq in inclusive_set (NULL acts as wildcard) and don't
00085  * find match_freq in exclusive_set (NULL acts as empty set).
00086  */
00087 gboolean        bse_freq_arrays_match_freq      (gfloat          match_freq,
00088                                                  BseFreqArray   *inclusive_set,
00089                                                  BseFreqArray   *exclusive_set);
00090 
00091 G_END_DECLS
00092 
00093 #endif /* __BSE_NOTE_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines