BEAST/BSE - Better Audio System and Sound Engine  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bsenote.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_NOTE_H__
3 #define __BSE_NOTE_H__
4 
5 #include <bse/bseglobals.hh>
6 #include <bse/bsetype.hh>
7 
8 G_BEGIN_DECLS
9 
10 /* --- import Sfi macros --- */
11 #define BSE_MIN_NOTE SFI_MIN_NOTE
12 #define BSE_MAX_NOTE SFI_MAX_NOTE
13 #define BSE_KAMMER_NOTE SFI_KAMMER_NOTE
14 #define BSE_NOTE_VOID SFI_NOTE_VOID
15 #define BSE_NOTE_UNPARSABLE SFI_NOTE_VOID
16 #define BSE_NOTE_CLAMP SFI_NOTE_CLAMP
17 #define BSE_NOTE_IS_VALID SFI_NOTE_IS_VALID
18 #define BSE_NOTE_MAKE_VALID SFI_NOTE_MAKE_VALID
19 #define BSE_KAMMER_OCTAVE SFI_KAMMER_OCTAVE
20 #define BSE_MIN_OCTAVE SFI_MIN_OCTAVE
21 #define BSE_MAX_OCTAVE SFI_MAX_OCTAVE
22 #define bse_note_from_string sfi_note_from_string
23 #define bse_note_to_string sfi_note_to_string
24 #define bse_note_examine sfi_note_examine
25 
26 
27 /* --- construct notes --- */
28 #define BSE_NOTE_OCTAVE(n) SFI_NOTE_OCTAVE (n)
29 #define BSE_NOTE_SEMITONE(n) SFI_NOTE_SEMITONE (n)
30 #define BSE_NOTE_GENERIC(o,ht_i) SFI_NOTE_GENERIC (o, ht_i)
31 #define BSE_NOTE_C(o) (BSE_NOTE_GENERIC ((o), 0))
32 #define BSE_NOTE_Cis(o) (BSE_NOTE_GENERIC ((o), 1))
33 #define BSE_NOTE_Des(o) (BSE_NOTE_Cis (o))
34 #define BSE_NOTE_D(o) (BSE_NOTE_GENERIC ((o), 2))
35 #define BSE_NOTE_Dis(o) (BSE_NOTE_GENERIC ((o), 3))
36 #define BSE_NOTE_Es(o) (BSE_NOTE_Dis (o))
37 #define BSE_NOTE_E(o) (BSE_NOTE_GENERIC ((o), 4))
38 #define BSE_NOTE_F(o) (BSE_NOTE_GENERIC ((o), 5))
39 #define BSE_NOTE_Fis(o) (BSE_NOTE_GENERIC ((o), 6))
40 #define BSE_NOTE_Ges(o) (BSE_NOTE_Fis (o))
41 #define BSE_NOTE_G(o) (BSE_NOTE_GENERIC ((o), 7))
42 #define BSE_NOTE_Gis(o) (BSE_NOTE_GENERIC ((o), 8))
43 #define BSE_NOTE_As(o) (BSE_NOTE_Gis (o))
44 #define BSE_NOTE_A(o) (BSE_NOTE_GENERIC ((o), 9))
45 #define BSE_NOTE_Ais(o) (BSE_NOTE_GENERIC ((o), 10))
46 #define BSE_NOTE_Bes(o) (BSE_NOTE_Ais (o))
47 #define BSE_NOTE_B(o) (BSE_NOTE_GENERIC ((o), 11))
48 #define BSE_NOTE_SHIFT(n,ht_i) SFI_NOTE_SHIFT (n, ht_i)
49 #define BSE_NOTE_OCTAVE_UP(n) (BSE_NOTE_SHIFT ((n), +12))
50 #define BSE_NOTE_OCTAVE_DOWN(n) (BSE_NOTE_SHIFT ((n), -12))
51 
52 
53 /* --- functions --- */
54 int bse_note_from_freq (BseMusicalTuningType musical_tuning,
55  double freq);
56 int bse_note_from_freq_bounded (BseMusicalTuningType musical_tuning,
57  double freq);
58 int bse_note_fine_tune_from_note_freq (BseMusicalTuningType musical_tuning,
59  int note,
60  double freq);
61 double bse_note_to_freq (BseMusicalTuningType musical_tuning,
62  int note);
63 double bse_note_to_tuned_freq (BseMusicalTuningType musical_tuning,
64  int note,
65  int fine_tune);
66 
67 
68 /* --- freq array --- */
69 typedef struct BseFreqArray BseFreqArray;
70 BseFreqArray* bse_freq_array_new (guint prealloc);
71 void bse_freq_array_free (BseFreqArray *farray);
72 guint bse_freq_array_n_values (BseFreqArray *farray);
73 gdouble bse_freq_array_get (BseFreqArray *farray,
74  guint index);
75 void bse_freq_array_insert (BseFreqArray *farray,
76  guint index,
77  gdouble value);
78 void bse_freq_array_append (BseFreqArray *farray,
79  gdouble value);
80 #define bse_freq_array_prepend(a,v) bse_freq_array_insert ((a), 0, (v))
81 void bse_freq_array_set (BseFreqArray *farray,
82  guint index,
83  gdouble value);
84 /* find match_freq in inclusive_set (NULL acts as wildcard) and don't
85  * find match_freq in exclusive_set (NULL acts as empty set).
86  */
87 gboolean bse_freq_arrays_match_freq (gfloat match_freq,
88  BseFreqArray *inclusive_set,
89  BseFreqArray *exclusive_set);
90 
91 G_END_DECLS
92 
93 #endif /* __BSE_NOTE_H__ */