[beast: 2/9] BSE: move MusicalTuningType, NoteDescription and related API to bseapi.idl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 2/9] BSE: move MusicalTuningType, NoteDescription and related API to bseapi.idl
- Date: Fri, 20 Nov 2015 22:08:40 +0000 (UTC)
commit e0f4e0a2b8a3c24e66488a1696d026e8c9663221
Author: Tim Janik <timj gnu org>
Date: Thu Nov 12 13:27:48 2015 +0100
BSE: move MusicalTuningType, NoteDescription and related API to bseapi.idl
Signed-off-by: Tim Janik <timj gnu org>
beast-gtk/bstpatterncolumns.cc | 13 ++--
bse/Makefile.am | 2 +-
bse/bseapi.idl | 121 ++++++++++++++++++++++++----
bse/bsebasics.idl | 95 ---------------------
bse/bsebiquadfilter.cc | 2 +-
bse/bsecxxmodule.cc | 2 +-
bse/bsecxxmodule.hh | 2 +-
bse/bseitem.cc | 6 +-
bse/bseitem.hh | 2 +-
bse/bseladspamodule.cc | 4 +-
bse/bsemathsignal.cc | 39 ++++-----
bse/bsemathsignal.hh | 5 +-
bse/bsemididecoder.cc | 4 +-
bse/bsemididecoder.hh | 4 +-
bse/bsemididevice.cc | 2 +-
bse/bsemidifile.cc | 2 +-
bse/bsemidifile.hh | 2 +-
bse/bsenote.cc | 57 ++++++++++---
bse/bsenote.hh | 31 +++----
bse/bsepart.cc | 2 +-
bse/bseprocedure.proc | 177 ----------------------------------------
bse/bseserver.cc | 40 +++++++++
bse/bseserver.hh | 6 ++
bse/bsesong.cc | 46 +++++------
bse/bsesong.hh | 26 +++---
bse/bsesource.cc | 6 +-
bse/bsesource.hh | 2 +-
bse/bsetool.cc | 12 ++--
bse/bseutils.cc | 36 --------
bse/bseutils.hh | 3 -
bse/tests/misctests.cc | 21 +++--
plugins/bseiirfilter.cc | 4 +-
plugins/bsesequencer.cc | 4 +-
plugins/davcanyondelay.cc | 2 +-
plugins/davorgan.cc | 2 +-
plugins/davsyndrum.cc | 2 +-
tools/bsewavetool.cc | 4 +-
37 files changed, 316 insertions(+), 474 deletions(-)
---
diff --git a/beast-gtk/bstpatterncolumns.cc b/beast-gtk/bstpatterncolumns.cc
index 8c16e8d..9f423e5 100644
--- a/beast-gtk/bstpatterncolumns.cc
+++ b/beast-gtk/bstpatterncolumns.cc
@@ -96,20 +96,19 @@ pattern_column_note_width_request (BstPatternColumn *column,
static char
pattern_column_note_char (BstPatternColumnNote *self, const Bse::PartNoteSeq &pseq, int pos)
{
- BseNoteDescription *ndesc;
if (pseq.size() == 0)
return '-';
else if (pseq.size() > 1)
return '*';
// pseq.size() == 1
- ndesc = bse_note_describe (BSE_MUSICAL_TUNING_12_TET, // tuning is irrelevant if we ignore ->freq
- pseq[0].note, pseq[0].fine_tune);
+ Bse::NoteDescription ndesc = bse_server.note_describe (Bse::MUSICAL_TUNING_12_TET, // tuning is irrelevant
if we ignore ->freq
+ pseq[0].note, pseq[0].fine_tune);
switch (pos)
{
- case 0: return ndesc->upshift ? '#' : ' ';
- case 1: return ndesc->letter;
- case 2: return ndesc->octave <= 0 ? '-' : '+';
- case 3: return ABS (ndesc->octave) + '0';
+ case 0: return ndesc.upshift ? '#' : ' ';
+ case 1: return ndesc.letter;
+ case 2: return ndesc.octave <= 0 ? '-' : '+';
+ case 3: return ABS (ndesc.octave) + '0';
default: return '-'; /* not reached */
}
}
diff --git a/bse/Makefile.am b/bse/Makefile.am
index 7a51e55..b7ed513 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -116,7 +116,7 @@ idl_dummy_files = $(strip \
# BSE procedure sources
bse_proc_sources = $(strip \
bsecategories.proc bsecontainer.proc bseeditablesample.proc \
- bsejanitor.proc bseprocedure.proc bseproject.proc \
+ bsejanitor.proc bseproject.proc \
bsesong.proc bsesource.proc \
bseitem.proc bsewave.proc bsewaveosc.proc
bsewaverepo.proc \
)
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 2a11f90..a8682be 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -274,6 +274,83 @@ enum MidiSignalType {
MIDI_SIGNAL_CONTROL_127 = Enum (255, _("Control 127 Polyphonic Mode On ITrigger")),
};
+// For musical tunings, see: http://en.wikipedia.org/wiki/Musical_tuning
+enum MusicalTuningType {
+ // Equal Temperament: http://en.wikipedia.org/wiki/Equal_temperament
+ MUSICAL_TUNING_12_TET = Enum (1, _("12 Tone Equal Temperament"), //
http://en.wikipedia.org/wiki/Equal_temperament
+ _("The most common tuning system for modern Western music, "
+ "is the twelve-tone equal temperament, abbreviated as 12-TET, "
+ "which divides the octave into 12 equal parts.")),
+ MUSICAL_TUNING_7_TET = Enum (_("7 Tone Equal Temperament"), //
http://en.wikipedia.org/wiki/Equal_temperament
+ _("A fairly common tuning system is the seven-tone equal
temperament tuning system, "
+ "abbreviated as 7-TET. It divides the octave into 7 equal parts
using 171 cent steps.")),
+ MUSICAL_TUNING_5_TET = Enum (_("5 Tone Equal Temperament"), //
http://en.wikipedia.org/wiki/Equal_temperament
+ _("A fairly common tuning system is the five-tone equal
temperament tuning system, "
+ "abbreviated as 5-TET. It divides the octave into 5 equal parts
using 240 cent steps.")),
+ // Rational Intonation: http://en.wikipedia.org/wiki/Just_intonation
+ MUSICAL_TUNING_DIATONIC_SCALE = Enum (_("Diatonic Scale"), //
http://en.wikipedia.org/wiki/Diatonic_scale
+ _("In music theory, a diatonic scale (also: heptatonia prima) is
a seven-note "
+ "musical scale comprising five whole-tone and two half-tone
steps. "
+ "The half tones are maximally separated, so between two
half-tone steps "
+ "there are either two or three whole tones, repeating per
octave.")), // Werckmeister I
+ MUSICAL_TUNING_INDIAN_SCALE = Enum (_("Indian Scale"), //
http://en.wikipedia.org/wiki/Just_intonation#Indian_scales
+ _("Diatonic scale used in Indian music with wolf interval at Dha,
close to 3/2")),
+ MUSICAL_TUNING_PYTHAGOREAN_TUNING= Enum (_("Pythagorean Tuning"), //
http://en.wikipedia.org/wiki/Pythagorean_tuning
+ _("Pythagorean tuning is the oldest way of tuning the 12-note
chromatic scale, "
+ "in which the frequency relationships of all intervals are
based on the ratio 3:2. "
+ "Its discovery is generally credited to Pythagoras.")),
+ MUSICAL_TUNING_PENTATONIC_5_LIMIT= Enum (_("Pentatonic 5-limit"), //
http://en.wikipedia.org/wiki/Pentatonic_scale
+ _("Pentatonic scales are used in modern jazz and pop/rock
contexts "
+ "because they work exceedingly well over several chords
diatonic "
+ "to the same key, often better than the parent scale.")),
+ MUSICAL_TUNING_PENTATONIC_BLUES = Enum (_("Pentatonic Blues"), //
http://en.wikipedia.org/wiki/Pentatonic_scale
+ _("The blues scale is the minor pentatonic with an additional
augmented fourth, "
+ "which is referred to as the \"blues note\".")),
+ MUSICAL_TUNING_PENTATONIC_GOGO = Enum (_("Pentatonic Gogo"), //
http://en.wikipedia.org/wiki/Pentatonic_scale
+ _("The Pentatonic Gogo scale is an anhemitonic pentatonic scale
used to tune the "
+ "instruments of the Gogo people of Tanzania.")),
+ // Meantone Temperament: http://en.wikipedia.org/wiki/Meantone_temperament
+ MUSICAL_TUNING_QUARTER_COMMA_MEANTONE = Enum (_("Quarter-Comma Meantone"), //
http://en.wikipedia.org/wiki/Quarter-comma_meantone
+ _("Quarter-comma meantone was the most common meantone
temperament in the "
+ "sixteenth and seventeenth centuries and sometimes used
later.")), // Werckmeister II
+ MUSICAL_TUNING_SILBERMANN_SORGE = Enum (_("Silbermann-Sorge Temperament"), //
http://de.wikipedia.org/wiki/Silbermann-Sorge-Temperatur
+ _("The Silbermann-Sorge temperament is a meantone temperament
used for "
+ "Baroque era organs by Gottfried Silbermann.")),
+ // Well Temperament: http://en.wikipedia.org/wiki/Well_temperament
+ MUSICAL_TUNING_WERCKMEISTER_3 = Enum (_("Werckmeister III"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
+ _("This tuning uses mostly pure (perfect) fifths, as in
Pythagorean tuning, but each "
+ "of the fifths C-G, G-D, D-A and B-F# is made smaller, i.e.
tempered by 1/4 comma. "
+ "Werckmeister designated this tuning as particularly suited for
playing chromatic music.")),
+ MUSICAL_TUNING_WERCKMEISTER_4 = Enum (_("Werckmeister IV"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
+ _("In this tuning the fifths C-G, D-A, E-B, F#-C#, and Bb-F are
tempered narrow by 1/3 comma, "
+ "and the fifths G#-D# and Eb-Bb are widened by 1/3 comma. The
other fifths are pure. "
+ "Most of its intervals are close to sixth-comma meantone. "
+ "Werckmeister designed this tuning for playing mainly diatonic
music.")),
+ MUSICAL_TUNING_WERCKMEISTER_5 = Enum (_("Werckmeister V"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
+ _("In this tuning the fifths D-A, A-E, F#-C#, C#-G#, and F-C are
narrowed by 1/4 comma, "
+ "and the fifth G#-D# is widened by 1/4 comma. The other fifths
are pure. "
+ "This temperament is closer to equal temperament than
Werckmeister III or IV.")),
+ MUSICAL_TUNING_WERCKMEISTER_6 = Enum (_("Werckmeister VI"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
+ _("This tuning is also known as Septenarius tuning is based on a
division of the monochord "
+ "length into 196 = 7 * 7 * 4 parts. "
+ "The resulting scale has rational frequency relationships, but
in practice involves pure "
+ "and impure sounding fifths. "
+ "Werckmeister described the Septenarius as a \"temperament
which has nothing at all to do "
+ "with the divisions of the comma, nevertheless in practice so
correct that one can be really "
+ "satisfied with it\".")),
+ MUSICAL_TUNING_KIRNBERGER_3 = Enum (_("Kirnberger III"), //
http://en.wikipedia.org/wiki/Johann_Philipp_Kirnberger_temperament
+ _("Kirnberger's method of compensating for and closing the circle
of fifths is to split the \"wolf\" "
+ "interval known to those who have used meantone temperaments
between four fifths instead, "
+ "allowing for four 1/4-comma wolves to take their place. "
+ "1/4-comma wolves are used extensively in meantone and are much
easier to tune and to listen to. "
+ "Therefore, only one third remains pure (between C and E).")),
+ MUSICAL_TUNING_YOUNG = Enum (_("Young Temperament"), //
http://en.wikipedia.org/wiki/Young_temperament
+ _("Thomas Young devised a form of musical tuning to make the
harmony most perfect in those keys which "
+ "are the most frequently used (give better major thirds in
those keys), but to not have any unplayable keys. "
+ "This is attempted by tuning upwards from C a sequence of six
pure fourths, "
+ "as well as six equally imperfect fifths.")),
+};
+
// == Bse Constants ==
Const MIN_NOTE = 0;
Const MAX_NOTE = 131; // 123
@@ -361,6 +438,20 @@ record SongTiming {
float64 stamp_ticks = Range ("Tick Increment", "Ticks per stamp increment (useful only during playback)",
STANDARD, 1, MAXINT31, 12, 384);
};
+/// A note description provides all needed details about a specific note. "
+record NoteDescription
+{
+ MusicalTuningType musical_tuning;
+ int32 note = Range ("Note", "", ":readwrite:note");
+ int32 octave = Range ("Octave", "", ":readwrite:octave");
+ float64 freq = Range ("Frequency", "", ":readwrite:freq");
+ int32 finetune = Range ("Finetune", "", ":readwrite:finetune", -100, +100, 10, 0);
+ int32 semitone = Range ("Semitone", "", ":readwrite", 0, 11, 1, 0);
+ bool upshift = Bool ("Upshift", "Flag set for notes that correspond to a black piano key");
+ int32 letter = Range ("Letter", "International abbreviation letter for this note",
":readwrite", 32, 126, 1, 64);
+ String name = String ("Name", "", ":readwrite");
+};
+
// Forward declarations.
record PartLink;
sequence PartLinkSeq;
@@ -653,14 +744,6 @@ interface Song : SNet {
// Bus get_master_bus (); ///< Retrieve master output bus of a song if it
exists.
// void synthesize_note (Track track, int32 duration, int32 note, int32 fine_tune, float64 velocity); ///<
Synthesize a note on a song of an active project.
// signal void pointer_changed (int32 a);
- // group _("Tuning") {
- // MusicalTuningType musical_tuning = Enum ("Musical Tuning",
- // "The tuning system which specifies the tones or pitches to
be used. "
- // "Due to the psychoacoustic properties of tones, various
pitch combinations can "
- // "sound 'natural' or 'pleasing' when used in combination. "
- // "The musical tuning system defines the number and spacing of
frequency values applied.",
- // STANDARD ":unprepared:skip-default",
BSE_MUSICAL_TUNING_12_TET);
- // };
// group _("Timing") {
// int32 tpqn = Range ("Ticks", "Number of ticks per quarter note", STANDARD, 384, 384, 0,
384);
// int32 numerator = Range ("Numerator", "Measure numerator", STANDARD, 1, 256, 1, 4);
@@ -675,7 +758,15 @@ interface Song : SNet {
// int32 loop_right = Range ("Loop Right", "", STORAGE, -1, MAXINT31, 384, -1);
// int32 tick_pointer = Range ("Tick Pointer", "", STORAGE, -1, MAXINT31, 384, -1);
group _("Timing") {
- float64 bpm = Range ("BPM", "Beats per minute", STANDARD ":scale", MIN_BPM, MAX_BPM, 10,
120);
+ float64 bpm = Range (_("BPM"), _("Beats per minute"), STANDARD ":scale", MIN_BPM, MAX_BPM,
10, 120);
+ };
+ group _("Tuning") {
+ MusicalTuningType musical_tuning = Enum (_("Musical Tuning"),
+ _("The tuning system which specifies the tones or pitches to be
used. "
+ "Due to the psychoacoustic properties of tones, various pitch
combinations can "
+ "sound \"natural\" or \"pleasing\" when used in combination,
the musical "
+ "tuning system defines the number and spacing of frequency
values applied."),
+ STANDARD ":unprepared");
};
};
@@ -795,17 +886,17 @@ interface Server : Object {
SampleFileInfo sample_file_info (String file_name); ///< Load sample file info from file.
/// Describe a note, providing information about its octave, semitone, frequency, etc.
- // NoteDescription note_describe (MusicalTuningType musical_tuning, int32 note, int32 fine_tune);
+ NoteDescription note_describe (MusicalTuningType musical_tuning, int32 note, int32 fine_tune);
// Describe a note, given its frequency.
- // NoteDescription note_describe_from_freq (MusicalTuningType musical_tuning, float64 freq);
+ NoteDescription note_describe_from_freq (MusicalTuningType musical_tuning, float64 freq);
/// Describe a note, given its semitone, octave and fine tune.
- // NoteDescription note_construct (MusicalTuningType musical_tuning, int32 semitone, int32 octave, int32
fine_tune);
+ NoteDescription note_construct (MusicalTuningType musical_tuning, int32 semitone, int32 octave, int32
fine_tune);
/// Describe a note, given its name and octave offset.
- // NoteDescription note_from_string (MusicalTuningType musical_tuning, String name);
+ NoteDescription note_from_string (MusicalTuningType musical_tuning, String name);
/// Retrieve the note of a certain frequency.
- // int32 note_from_freq (MusicalTuningType musical_tuning, float64 frequency);
+ int32 note_from_freq (MusicalTuningType musical_tuning, float64 frequency);
/// Retrieve the frequency of a certain note.
- // float64 note_to_freq (MusicalTuningType musical_tuning, int32 note, int32 fine_tune);
+ float64 note_to_freq (MusicalTuningType musical_tuning, int32 note, int32 fine_tune);
// *** Old Janitor ***
// void trigger_action (String action); ///< Trigger an installed user action of this janitor.
diff --git a/bse/bsebasics.idl b/bse/bsebasics.idl
index 4a9c30f..edbee5c 100644
--- a/bse/bsebasics.idl
+++ b/bse/bsebasics.idl
@@ -26,82 +26,6 @@ sequence TypeSeq {
sequence FloatSeq {
Real values;
};
-/* musical tunings: http://en.wikipedia.org/wiki/Musical_tuning */
-enum MusicalTuningType {
- /* Equal Temperament: http://en.wikipedia.org/wiki/Equal_temperament */
- MUSICAL_TUNING_12_TET = Enum (1, _("12 Tone Equal Temperament"), //
http://en.wikipedia.org/wiki/Equal_temperament
- _("The most common tuning system for modern Western music, "
- "is the twelve-tone equal temperament, abbreviated as 12-TET, "
- "which divides the octave into 12 equal parts.")),
- MUSICAL_TUNING_7_TET = Enum (_("7 Tone Equal Temperament"), //
http://en.wikipedia.org/wiki/Equal_temperament
- _("A fairly common tuning system is the seven-tone equal
temperament tuning system, "
- "abbreviated as 7-TET. It divides the octave into 7 equal parts
using 171 cent steps.")),
- MUSICAL_TUNING_5_TET = Enum (_("5 Tone Equal Temperament"), //
http://en.wikipedia.org/wiki/Equal_temperament
- _("A fairly common tuning system is the five-tone equal
temperament tuning system, "
- "abbreviated as 5-TET. It divides the octave into 5 equal parts
using 240 cent steps.")),
- /* Rational Intonation: http://en.wikipedia.org/wiki/Just_intonation */
- MUSICAL_TUNING_DIATONIC_SCALE = Enum (_("Diatonic Scale"), //
http://en.wikipedia.org/wiki/Diatonic_scale
- _("In music theory, a diatonic scale (also: heptatonia prima) is
a seven-note "
- "musical scale comprising five whole-tone and two half-tone
steps. "
- "The half tones are maximally separated, so between two
half-tone steps "
- "there are either two or three whole tones, repeating per
octave.")), // Werckmeister I
- MUSICAL_TUNING_INDIAN_SCALE = Enum (_("Indian Scale"), //
http://en.wikipedia.org/wiki/Just_intonation#Indian_scales
- _("Diatonic scale used in Indian music with wolf interval at Dha,
close to 3/2")),
- MUSICAL_TUNING_PYTHAGOREAN_TUNING= Enum (_("Pythagorean Tuning"), //
http://en.wikipedia.org/wiki/Pythagorean_tuning
- _("Pythagorean tuning is the oldest way of tuning the 12-note
chromatic scale, "
- "in which the frequency relationships of all intervals are
based on the ratio 3:2. "
- "Its discovery is generally credited to Pythagoras.")),
- MUSICAL_TUNING_PENTATONIC_5_LIMIT= Enum (_("Pentatonic 5-limit"), //
http://en.wikipedia.org/wiki/Pentatonic_scale
- _("Pentatonic scales are used in modern jazz and pop/rock
contexts "
- "because they work exceedingly well over several chords
diatonic "
- "to the same key, often better than the parent scale.")),
- MUSICAL_TUNING_PENTATONIC_BLUES = Enum (_("Pentatonic Blues"), //
http://en.wikipedia.org/wiki/Pentatonic_scale
- _("The blues scale is the minor pentatonic with an additional
augmented fourth, "
- "which is referred to as the \"blues note\".")),
- MUSICAL_TUNING_PENTATONIC_GOGO = Enum (_("Pentatonic Gogo"), //
http://en.wikipedia.org/wiki/Pentatonic_scale
- _("The Pentatonic Gogo scale is an anhemitonic pentatonic scale
used to tune the "
- "instruments of the Gogo people of Tanzania.")),
- /* Meantone Temperament: http://en.wikipedia.org/wiki/Meantone_temperament */
- MUSICAL_TUNING_QUARTER_COMMA_MEANTONE = Enum (_("Quarter-Comma Meantone"), //
http://en.wikipedia.org/wiki/Quarter-comma_meantone
- _("Quarter-comma meantone was the most common meantone
temperament in the "
- "sixteenth and seventeenth centuries and sometimes used
later.")), // Werckmeister II
- MUSICAL_TUNING_SILBERMANN_SORGE = Enum (_("Silbermann-Sorge Temperament"), //
http://de.wikipedia.org/wiki/Silbermann-Sorge-Temperatur
- _("The Silbermann-Sorge temperament is a meantone temperament
used for "
- "Baroque era organs by Gottfried Silbermann.")),
- /* Well Temperament: http://en.wikipedia.org/wiki/Well_temperament */
- MUSICAL_TUNING_WERCKMEISTER_3 = Enum (_("Werckmeister III"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
- _("This tuning uses mostly pure (perfect) fifths, as in
Pythagorean tuning, but each "
- "of the fifths C-G, G-D, D-A and B-F# is made smaller, i.e.
tempered by 1/4 comma. "
- "Werckmeister designated this tuning as particularly suited for
playing chromatic music.")),
- MUSICAL_TUNING_WERCKMEISTER_4 = Enum (_("Werckmeister IV"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
- _("In this tuning the fifths C-G, D-A, E-B, F#-C#, and Bb-F are
tempered narrow by 1/3 comma, "
- "and the fifths G#-D# and Eb-Bb are widened by 1/3 comma. The
other fifths are pure. "
- "Most of its intervals are close to sixth-comma meantone. "
- "Werckmeister designed this tuning for playing mainly diatonic
music.")),
- MUSICAL_TUNING_WERCKMEISTER_5 = Enum (_("Werckmeister V"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
- _("In this tuning the fifths D-A, A-E, F#-C#, C#-G#, and F-C are
narrowed by 1/4 comma, "
- "and the fifth G#-D# is widened by 1/4 comma. The other fifths
are pure. "
- "This temperament is closer to equal temperament than
Werckmeister III or IV.")),
- MUSICAL_TUNING_WERCKMEISTER_6 = Enum (_("Werckmeister VI"), //
http://en.wikipedia.org/wiki/Werckmeister_temperament
- _("This tuning is also known as Septenarius tuning is based on a
division of the monochord "
- "length into 196 = 7 * 7 * 4 parts. "
- "The resulting scale has rational frequency relationships, but
in practice involves pure "
- "and impure sounding fifths. "
- "Werckmeister described the Septenarius as a \"temperament
which has nothing at all to do "
- "with the divisions of the comma, nevertheless in practice so
correct that one can be really "
- "satisfied with it\".")),
- MUSICAL_TUNING_KIRNBERGER_3 = Enum (_("Kirnberger III"), //
http://en.wikipedia.org/wiki/Johann_Philipp_Kirnberger_temperament
- _("Kirnberger's method of compensating for and closing the circle
of fifths is to split the \"wolf\" "
- "interval known to those who have used meantone temperaments
between four fifths instead, "
- "allowing for four 1/4-comma wolves to take their place. "
- "1/4-comma wolves are used extensively in meantone and are much
easier to tune and to listen to. "
- "Therefore, only one third remains pure (between C and E).")),
- MUSICAL_TUNING_YOUNG = Enum (_("Young Temperament"), //
http://en.wikipedia.org/wiki/Young_temperament
- _("Thomas Young devised a form of musical tuning to make the
harmony most perfect in those keys which "
- "are the most frequently used (give better major thirds in
those keys), but to not have any unplayable keys. "
- "This is attempted by tuning upwards from C a sequence of six
pure fourths, "
- "as well as six equally imperfect fifths.")),
-};
enum MidiControlType {
/* special cased signals */
MIDI_CONTROL_NONE = Enum (0, _("None")),
@@ -330,25 +254,6 @@ record PropertyCandidates {
It3mSeq items;
TypeSeq partitions = SfiSeq ("Type Partitions", "List of types which may logically partition the list of
items by type discrimination", STANDARD);
};
-record NoteDescription
-{
- MusicalTuningType musical_tuning;
- Int note = Note ("Note", "", KAMMER_NOTE, ":readwrite");
- Int octave = Octave ("Octave", "", KAMMER_OCTAVE, ":readwrite");
- Real freq = Freq ("Frequency", "", KAMMER_FREQ, ":readwrite");
- Int fine_tune = FineTune ("Fine Tune", "", ":readwrite");
- Int semitone = SfiInt ("Semitone", "", 0, 0, 11, 1, ":readwrite");
- Bool upshift;
- Int letter = SfiInt ("Letter", "International abbreviation letter for this note", 64, 32, 126,
1, ":readwrite");
- SfiString name = SfiString ("Name", "", "", ":readwrite");
- /* constants */
- Int max_fine_tune = SfiInt ("Max Fine Tune", "", MAX_FINE_TUNE, MAX_FINE_TUNE, MAX_FINE_TUNE, 0,
":readable");
- Int kammer_note = SfiInt ("Kammer Note", "", KAMMER_NOTE, KAMMER_NOTE, KAMMER_NOTE, 0, ":readable");
- Info blurb = "A note description provides all necessary details about a specific note. "
- "Various procedures exist to retrieve a note description; given different "
- "key values. The max_fine_tune and kammer_note fields are constants, which "
- "are provided for compatibility reasons and will vanish in future APIs.";
-};
record NoteSequence
{
Int offset = Note ("Note Offset", "Center/base note", KAMMER_NOTE, ":readwrite");
diff --git a/bse/bsebiquadfilter.cc b/bse/bsebiquadfilter.cc
index 178f449..58dddc3 100644
--- a/bse/bsebiquadfilter.cc
+++ b/bse/bsebiquadfilter.cc
@@ -123,7 +123,7 @@ bse_biquad_filter_class_init (BseBiquadFilterClass *klass)
PROP_NOTE,
sfi_pspec_note ("note", _("Note"), _("Filter cutoff frequency as note, "
"converted to Hertz according to the
current musical tuning"),
- bse_note_from_freq (BSE_MUSICAL_TUNING_12_TET,
BSE_KAMMER_FREQUENCY * 2),
+ bse_note_from_freq (Bse::MUSICAL_TUNING_12_TET,
BSE_KAMMER_FREQUENCY * 2),
BSE_MIN_NOTE, BSE_MAX_NOTE,
FALSE,
SFI_PARAM_GUI));
diff --git a/bse/bsecxxmodule.cc b/bse/bsecxxmodule.cc
index df95aee..9f1f37f 100644
--- a/bse/bsecxxmodule.cc
+++ b/bse/bsecxxmodule.cc
@@ -411,7 +411,7 @@ Effect::max_block_size() const
return BSE_STREAM_MAX_VALUES;
}
-BseMusicalTuningType
+Bse::MusicalTuningType
Effect::current_musical_tuning() const
{
BseSource *source = cast (const_cast <Effect*> (this));
diff --git a/bse/bsecxxmodule.hh b/bse/bsecxxmodule.hh
index a90af22..60af66b 100644
--- a/bse/bsecxxmodule.hh
+++ b/bse/bsecxxmodule.hh
@@ -145,7 +145,7 @@ protected:
uint block_size () const;
uint max_block_size () const;
public: /* FIXME: make this protected as soon as the modules have their own current_musical_tuning()
accessor */
- BseMusicalTuningType current_musical_tuning () const;
+ Bse::MusicalTuningType current_musical_tuning () const;
};
/* implement Bse::Effect and Bse::SynthesisModule methods */
#define BSE_EFFECT_INTEGRATE_MODULE(ObjectType,ModuleType,ParamType) \
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 6a5623b..2a17de5 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -697,10 +697,10 @@ bse_item_has_ancestor (BseItem *item,
* The musical tuning depends on project wide settings that may change after
* this funciton has been called, so the result should be used with caution.
*/
-BseMusicalTuningType
+Bse::MusicalTuningType
bse_item_current_musical_tuning (BseItem *self)
{
- assert_return (BSE_IS_ITEM (self), BSE_MUSICAL_TUNING_12_TET);
+ assert_return (BSE_IS_ITEM (self), Bse::MUSICAL_TUNING_12_TET);
/* finding the musical tuning *should* be possible by just visiting
* an items parents. however, .bse objects are not currently (0.7.1)
* structured that way, so we get the tuning from the first song in
@@ -714,7 +714,7 @@ bse_item_current_musical_tuning (BseItem *self)
if (BSE_IS_SONG (slist->data))
return BSE_SONG (slist->data)->musical_tuning;
}
- return BSE_MUSICAL_TUNING_12_TET;
+ return Bse::MUSICAL_TUNING_12_TET;
}
static inline GType
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index c4d604a..cc8de67 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -143,7 +143,7 @@ void bse_item_push_undo_storage (BseItem *self,
/* convenience */
#define bse_item_set bse_item_set_undoable
#define bse_item_get g_object_get
-BseMusicalTuningType bse_item_current_musical_tuning (BseItem *self);
+Bse::MusicalTuningType bse_item_current_musical_tuning (BseItem *self);
G_END_DECLS
diff --git a/bse/bseladspamodule.cc b/bse/bseladspamodule.cc
index 06655d5..4b4d091 100644
--- a/bse/bseladspamodule.cc
+++ b/bse/bseladspamodule.cc
@@ -173,8 +173,8 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
if (port->concert_a)
{
/* when defaulting to A', we probably have note-aligned port values */
- int min_note = bse_note_from_freq_bounded (BSE_MUSICAL_TUNING_12_TET, minimum);
- int max_note = bse_note_from_freq_bounded (BSE_MUSICAL_TUNING_12_TET, maximum);
+ int min_note = bse_note_from_freq_bounded (Bse::MUSICAL_TUNING_12_TET, minimum);
+ int max_note = bse_note_from_freq_bounded (Bse::MUSICAL_TUNING_12_TET, maximum);
if (max_note - min_note > 2)
{
char *ident2 = g_strconcat (port->ident, "-note", NULL);
diff --git a/bse/bsemathsignal.cc b/bse/bsemathsignal.cc
index c7d9786..c6fbb63 100644
--- a/bse/bsemathsignal.cc
+++ b/bse/bsemathsignal.cc
@@ -587,55 +587,54 @@ static const double semitone_table265_young_temperament[132 + 1 + 132] = {
};
const double*
-bse_semitone_table_from_tuning (BseMusicalTuningType musical_tuning)
+bse_semitone_table_from_tuning (Bse::MusicalTuningType musical_tuning)
{
switch (musical_tuning)
{
/* Equal Temperament: http://en.wikipedia.org/wiki/Equal_temperament */
default:
- case BSE_MUSICAL_TUNING_12_TET:
+ case Bse::MUSICAL_TUNING_12_TET:
return 132 + semitone_table265_equal_temperament_12_tet;
- case BSE_MUSICAL_TUNING_7_TET:
+ case Bse::MUSICAL_TUNING_7_TET:
return 132 + semitone_table265_equal_temperament_7_tet;
- case BSE_MUSICAL_TUNING_5_TET:
+ case Bse::MUSICAL_TUNING_5_TET:
return 132 + semitone_table265_equal_temperament_5_tet;
/* Rational Intonation: http://en.wikipedia.org/wiki/Just_intonation */
- case BSE_MUSICAL_TUNING_DIATONIC_SCALE:
+ case Bse::MUSICAL_TUNING_DIATONIC_SCALE:
return 132 + semitone_table265_diatonic_scale;
- case BSE_MUSICAL_TUNING_INDIAN_SCALE:
+ case Bse::MUSICAL_TUNING_INDIAN_SCALE:
return 132 + semitone_table265_indian_scale;
- case BSE_MUSICAL_TUNING_PYTHAGOREAN_TUNING:
+ case Bse::MUSICAL_TUNING_PYTHAGOREAN_TUNING:
return 132 + semitone_table265_pythagorean_tuning;
- case BSE_MUSICAL_TUNING_PENTATONIC_5_LIMIT:
+ case Bse::MUSICAL_TUNING_PENTATONIC_5_LIMIT:
return 132 + semitone_table265_pentatonic_5_limit;
- case BSE_MUSICAL_TUNING_PENTATONIC_BLUES:
+ case Bse::MUSICAL_TUNING_PENTATONIC_BLUES:
return 132 + semitone_table265_pentatonic_blues;
- case BSE_MUSICAL_TUNING_PENTATONIC_GOGO:
+ case Bse::MUSICAL_TUNING_PENTATONIC_GOGO:
return 132 + semitone_table265_pentatonic_gogo;
/* Meantone Temperament: http://en.wikipedia.org/wiki/Meantone_temperament */
- case BSE_MUSICAL_TUNING_QUARTER_COMMA_MEANTONE:
+ case Bse::MUSICAL_TUNING_QUARTER_COMMA_MEANTONE:
return 132 + semitone_table265_quarter_comma_meantone;
- case BSE_MUSICAL_TUNING_SILBERMANN_SORGE:
+ case Bse::MUSICAL_TUNING_SILBERMANN_SORGE:
return 132 + semitone_table265_silbermann_sorge_temperament;
/* Well Temperament: http://en.wikipedia.org/wiki/Well_temperament */
- case BSE_MUSICAL_TUNING_WERCKMEISTER_3:
+ case Bse::MUSICAL_TUNING_WERCKMEISTER_3:
return 132 + semitone_table265_werckmeister3_temperament;
- case BSE_MUSICAL_TUNING_WERCKMEISTER_4:
+ case Bse::MUSICAL_TUNING_WERCKMEISTER_4:
return 132 + semitone_table265_werckmeister4_temperament;
- case BSE_MUSICAL_TUNING_WERCKMEISTER_5:
+ case Bse::MUSICAL_TUNING_WERCKMEISTER_5:
return 132 + semitone_table265_werckmeister5_temperament;
- case BSE_MUSICAL_TUNING_WERCKMEISTER_6:
+ case Bse::MUSICAL_TUNING_WERCKMEISTER_6:
return 132 + semitone_table265_werckmeister6_temperament;
- case BSE_MUSICAL_TUNING_KIRNBERGER_3:
+ case Bse::MUSICAL_TUNING_KIRNBERGER_3:
return 132 + semitone_table265_kirnberger_temperament;
- case BSE_MUSICAL_TUNING_YOUNG:
+ case Bse::MUSICAL_TUNING_YOUNG:
return 132 + semitone_table265_young_temperament;
}
}
double
-bse_transpose_factor (BseMusicalTuningType musical_tuning,
- int index /* [-132..+132] */)
+bse_transpose_factor (Bse::MusicalTuningType musical_tuning, int index /* [-132..+132] */)
{
const double *table = bse_semitone_table_from_tuning (musical_tuning);
return table[CLAMP (index, -132, +132)];
diff --git a/bse/bsemathsignal.hh b/bse/bsemathsignal.hh
index aef1574..b58b914 100644
--- a/bse/bsemathsignal.hh
+++ b/bse/bsemathsignal.hh
@@ -378,9 +378,8 @@ static inline double bse_saturate_branching (double value,
double limit) G_GNUC_CONST;
/* --- semitone factors (for +-11 octaves) --- */
-const double* bse_semitone_table_from_tuning (BseMusicalTuningType musical_tuning); /* returns [-132..+132]
*/
-double bse_transpose_factor (BseMusicalTuningType musical_tuning,
- int index /* [-132..+132] */);
+const double* bse_semitone_table_from_tuning (Bse::MusicalTuningType musical_tuning); /* returns
[-132..+132] */
+double bse_transpose_factor (Bse::MusicalTuningType musical_tuning, int index /*
[-132..+132] */);
/* --- cents (1/100th of a semitone) --- */
diff --git a/bse/bsemididecoder.cc b/bse/bsemididecoder.cc
index 40ec567..f70a938 100644
--- a/bse/bsemididecoder.cc
+++ b/bse/bsemididecoder.cc
@@ -11,9 +11,7 @@ static void bse_midi_decoder_construct_event (BseMidiDecoder *self);
/* --- function --- */
BseMidiDecoder*
-bse_midi_decoder_new (gboolean auto_queue,
- gboolean smf_support,
- BseMusicalTuningType musical_tuning)
+bse_midi_decoder_new (gboolean auto_queue, gboolean smf_support, Bse::MusicalTuningType musical_tuning)
{
BseMidiDecoder *self;
diff --git a/bse/bsemididecoder.hh b/bse/bsemididecoder.hh
index d1280ef..8e29b4b 100644
--- a/bse/bsemididecoder.hh
+++ b/bse/bsemididecoder.hh
@@ -22,7 +22,7 @@ typedef enum {
struct BseMidiDecoder {
SfiRing *events; /* BseMidiEvent* */
/* configuration */
- BseMusicalTuningType musical_tuning;
+ Bse::MusicalTuningType musical_tuning;
uint auto_queue : 1;
uint smf_support : 1;
/*< private >*/
@@ -42,7 +42,7 @@ struct BseMidiDecoder {
/* --- API --- */
BseMidiDecoder* bse_midi_decoder_new (gboolean auto_queue,
gboolean smf_support,
- BseMusicalTuningType musical_tuning);
+ Bse::MusicalTuningType musical_tuning);
void bse_midi_decoder_destroy (BseMidiDecoder *self);
void bse_midi_decoder_push_data (BseMidiDecoder *self,
uint n_bytes,
diff --git a/bse/bsemididevice.cc b/bse/bsemididevice.cc
index a6d675e..fcf3c9b 100644
--- a/bse/bsemididevice.cc
+++ b/bse/bsemididevice.cc
@@ -14,7 +14,7 @@ static void *parent_class = NULL;
static void
bse_midi_device_init (BseMidiDevice *self)
{
- self->midi_decoder = bse_midi_decoder_new (TRUE, FALSE, BSE_MUSICAL_TUNING_12_TET);
+ self->midi_decoder = bse_midi_decoder_new (TRUE, FALSE, Bse::MUSICAL_TUNING_12_TET);
self->handle = NULL;
}
diff --git a/bse/bsemidifile.cc b/bse/bsemidifile.cc
index 8f4e76f..4bcd93e 100644
--- a/bse/bsemidifile.cc
+++ b/bse/bsemidifile.cc
@@ -167,7 +167,7 @@ bse_midi_file_load (const char *file_name,
}
smf = (BseMidiFile*) g_malloc0 (sizeof (BseMidiFile) + header.n_tracks * sizeof (smf->tracks[0]));
- smf->musical_tuning = BSE_MUSICAL_TUNING_12_TET;
+ smf->musical_tuning = Bse::MUSICAL_TUNING_12_TET;
#if 0
smf->tpqn = header.division;
smf->tpqn_rate = 1;
diff --git a/bse/bsemidifile.hh b/bse/bsemidifile.hh
index 7aa3763..dfefdf2 100644
--- a/bse/bsemidifile.hh
+++ b/bse/bsemidifile.hh
@@ -11,7 +11,7 @@ typedef struct {
BseMidiEvent **events;
} BseMidiFileTrack;
typedef struct {
- BseMusicalTuningType musical_tuning;
+ Bse::MusicalTuningType musical_tuning;
guint tpqn; /* ticks-per-quarter-note */
gfloat tpqn_rate;
/* signature */
diff --git a/bse/bsenote.cc b/bse/bsenote.cc
index 0aab263..34c1bd0 100644
--- a/bse/bsenote.cc
+++ b/bse/bsenote.cc
@@ -5,12 +5,48 @@
#include "bsemathsignal.hh"
#include <string.h>
#include <sfi/sfi.hh>
+
+
/* --- functions --- */
+int
+bse_note_from_string (const String ¬e_string)
+{
+ return sfi_note_from_string (note_string.c_str());
+}
+
+Bse::NoteDescription
+bse_note_description (Bse::MusicalTuningType musical_tuning, int note, int finetune)
+{
+ Bse::NoteDescription info;
+ info.musical_tuning = musical_tuning;
+ if (note >= BSE_MIN_NOTE && note <= BSE_MAX_NOTE)
+ {
+ char letter;
+ info.note = note;
+ int black_semitone = false;
+ bse_note_examine (info.note,
+ &info.octave,
+ &info.semitone,
+ &black_semitone,
+ &letter);
+ info.upshift = black_semitone;
+ info.letter = letter;
+ info.finetune = CLAMP (finetune, BSE_MIN_FINE_TUNE, BSE_MAX_FINE_TUNE);
+ info.freq = bse_note_to_tuned_freq (musical_tuning, info.note, info.finetune);
+ info.name = bse_note_to_string (info.note);
+ }
+ else
+ {
+ info.note = BSE_NOTE_VOID;
+ info.name = "";
+ }
+ return info;
+}
+
namespace {
struct FreqCmp {
inline int
- operator() (float f1,
- float f2)
+ operator() (float f1, float f2)
{
return f1 < f2 ? -1 : f1 > f2;
}
@@ -18,8 +54,7 @@ struct FreqCmp {
} // Anon
int
-bse_note_from_freq (BseMusicalTuningType musical_tuning,
- double freq)
+bse_note_from_freq (Bse::MusicalTuningType musical_tuning, double freq)
{
freq /= BSE_KAMMER_FREQUENCY;
const double *table = bse_semitone_table_from_tuning (musical_tuning);
@@ -52,8 +87,7 @@ bse_note_from_freq (BseMusicalTuningType musical_tuning,
}
int
-bse_note_from_freq_bounded (BseMusicalTuningType musical_tuning,
- double freq)
+bse_note_from_freq_bounded (Bse::MusicalTuningType musical_tuning, double freq)
{
int note = bse_note_from_freq (musical_tuning, freq);
if (note != BSE_NOTE_VOID)
@@ -63,9 +97,7 @@ bse_note_from_freq_bounded (BseMusicalTuningType musical_tuning,
}
int
-bse_note_fine_tune_from_note_freq (BseMusicalTuningType musical_tuning,
- int note,
- double freq)
+bse_note_fine_tune_from_note_freq (Bse::MusicalTuningType musical_tuning, int note, double freq)
{
double semitone_factor = bse_transpose_factor (musical_tuning, CLAMP (note, BSE_MIN_NOTE, BSE_MAX_NOTE) -
SFI_KAMMER_NOTE);
freq /= BSE_KAMMER_FREQUENCY * semitone_factor;
@@ -76,8 +108,7 @@ bse_note_fine_tune_from_note_freq (BseMusicalTuningType musical_tuning,
}
double
-bse_note_to_freq (BseMusicalTuningType musical_tuning,
- int note)
+bse_note_to_freq (Bse::MusicalTuningType musical_tuning, int note)
{
if (note < BSE_MIN_NOTE || note > BSE_MAX_NOTE)
return 0.0;
@@ -86,9 +117,7 @@ bse_note_to_freq (BseMusicalTuningType musical_tuning,
}
double
-bse_note_to_tuned_freq (BseMusicalTuningType musical_tuning,
- int note,
- int fine_tune)
+bse_note_to_tuned_freq (Bse::MusicalTuningType musical_tuning, int note, int fine_tune)
{
if (note < BSE_MIN_NOTE || note > BSE_MAX_NOTE)
return 0.0;
diff --git a/bse/bsenote.hh b/bse/bsenote.hh
index 66ade20..a09383c 100644
--- a/bse/bsenote.hh
+++ b/bse/bsenote.hh
@@ -2,12 +2,12 @@
#ifndef __BSE_NOTE_H__
#define __BSE_NOTE_H__
-#include <bse/bseglobals.hh>
-#include <bse/bsetype.hh>
+#include <bse/bseglobals.hh>
+#include <bse/bseenums.hh>
G_BEGIN_DECLS
-/* --- import Sfi macros --- */
+// == Sfi imports ==
#define BSE_MIN_NOTE SFI_MIN_NOTE
#define BSE_MAX_NOTE SFI_MAX_NOTE
#define BSE_KAMMER_NOTE SFI_KAMMER_NOTE
@@ -19,12 +19,10 @@ G_BEGIN_DECLS
#define BSE_KAMMER_OCTAVE SFI_KAMMER_OCTAVE
#define BSE_MIN_OCTAVE SFI_MIN_OCTAVE
#define BSE_MAX_OCTAVE SFI_MAX_OCTAVE
-#define bse_note_from_string sfi_note_from_string
#define bse_note_to_string sfi_note_to_string
#define bse_note_examine sfi_note_examine
-
-/* --- construct notes --- */
+// == Construct Notes ==
#define BSE_NOTE_OCTAVE(n) SFI_NOTE_OCTAVE (n)
#define BSE_NOTE_SEMITONE(n) SFI_NOTE_SEMITONE (n)
#define BSE_NOTE_GENERIC(o,ht_i) SFI_NOTE_GENERIC (o, ht_i)
@@ -49,20 +47,15 @@ G_BEGIN_DECLS
#define BSE_NOTE_OCTAVE_UP(n) (BSE_NOTE_SHIFT ((n), +12))
#define BSE_NOTE_OCTAVE_DOWN(n) (BSE_NOTE_SHIFT ((n), -12))
+// Internals, use Bse::Server API instead
+int bse_note_from_freq (Bse::MusicalTuningType musical_tuning, double freq);
+int bse_note_from_freq_bounded (Bse::MusicalTuningType musical_tuning, double freq);
+int bse_note_fine_tune_from_note_freq (Bse::MusicalTuningType musical_tuning, int note, double freq);
+double bse_note_to_freq (Bse::MusicalTuningType musical_tuning, int note);
+double bse_note_to_tuned_freq (Bse::MusicalTuningType musical_tuning, int note, int fine_tune);
-/* --- functions --- */
-int bse_note_from_freq (BseMusicalTuningType musical_tuning,
- double freq);
-int bse_note_from_freq_bounded (BseMusicalTuningType musical_tuning,
- double freq);
-int bse_note_fine_tune_from_note_freq (BseMusicalTuningType musical_tuning,
- int note,
- double freq);
-double bse_note_to_freq (BseMusicalTuningType musical_tuning,
- int note);
-double bse_note_to_tuned_freq (BseMusicalTuningType musical_tuning,
- int note,
- int fine_tune);
+Bse::NoteDescription bse_note_description (Bse::MusicalTuningType musical_tuning, int note, int finetune);
+int bse_note_from_string (const String ¬e_string);
/* --- freq array --- */
diff --git a/bse/bsepart.cc b/bse/bsepart.cc
index addc7f1..3b71a6c 100644
--- a/bse/bsepart.cc
+++ b/bse/bsepart.cc
@@ -127,7 +127,7 @@ bse_part_class_init (BsePartClass *klass)
static void
bse_part_init (BsePart *self)
{
- self->semitone_table = bse_semitone_table_from_tuning (BSE_MUSICAL_TUNING_12_TET);
+ self->semitone_table = bse_semitone_table_from_tuning (Bse::MUSICAL_TUNING_12_TET);
self->n_ids = 0;
self->ids = NULL;
self->last_id = 0;
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index d34ff3d..04cf5ae 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -1571,4 +1571,44 @@ ServerImpl::sample_file_info (const String &filename)
return info;
}
+NoteDescription
+ServerImpl::note_describe_from_freq (MusicalTuningType musical_tuning, double freq)
+{
+ const int note = bse_note_from_freq (musical_tuning, freq);
+ return bse_note_description (musical_tuning, note, 0);
+}
+
+NoteDescription
+ServerImpl::note_describe (MusicalTuningType musical_tuning, int note, int fine_tune)
+{
+ return bse_note_description (musical_tuning, note, fine_tune);
+}
+
+NoteDescription
+ServerImpl::note_construct (MusicalTuningType musical_tuning, int semitone, int octave, int fine_tune)
+{
+ const int note = BSE_NOTE_GENERIC (octave, semitone);
+ return bse_note_description (musical_tuning, note, fine_tune);
+}
+
+NoteDescription
+ServerImpl::note_from_string (MusicalTuningType musical_tuning, const String &name)
+{
+ const int note = bse_note_from_string (name);
+ return bse_note_description (musical_tuning, note, 0);
+}
+
+int
+ServerImpl::note_from_freq (MusicalTuningType musical_tuning, double frequency)
+{
+ return bse_note_from_freq (musical_tuning, frequency);
+}
+
+double
+ServerImpl::note_to_freq (MusicalTuningType musical_tuning, int note, int fine_tune)
+{
+ const Bse::NoteDescription info = bse_note_description (musical_tuning, note, fine_tune);
+ return info.name.empty() ? 0 : info.freq;
+}
+
} // Bse
diff --git a/bse/bseserver.hh b/bse/bseserver.hh
index bc893a2..f9cdb04 100644
--- a/bse/bseserver.hh
+++ b/bse/bseserver.hh
@@ -132,6 +132,12 @@ public:
virtual AuxData find_module_type (const String &module_type) override;
virtual Icon module_type_icon (const String &module_type) override;
virtual SampleFileInfo sample_file_info (const String &filename) override;
+ virtual NoteDescription note_describe_from_freq (MusicalTuningType musical_tuning, double freq) override;
+ virtual NoteDescription note_describe (MusicalTuningType musical_tuning, int note, int fine_tune)
override;
+ virtual NoteDescription note_construct (MusicalTuningType musical_tuning, int semitone, int octave, int
fine_tune) override;
+ virtual NoteDescription note_from_string (MusicalTuningType musical_tuning, const String &name) override;
+ virtual int note_from_freq (MusicalTuningType musical_tuning, double frequency) override;
+ virtual double note_to_freq (MusicalTuningType musical_tuning, int note, int fine_tune)
override;
void send_user_message (const UserMessage &umsg);
static void register_source_module (const String &type, const String &title, const String &tags,
const uint8 *pixstream);
static ServerImpl& instance ();
diff --git a/bse/bsesong.cc b/bse/bsesong.cc
index 19fde7b..a657262 100644
--- a/bse/bsesong.cc
+++ b/bse/bsesong.cc
@@ -20,7 +20,6 @@
enum
{
PROP_0,
- PROP_MUSICAL_TUNING,
PROP_TPQN,
PROP_NUMERATOR,
PROP_DENOMINATOR,
@@ -150,15 +149,6 @@ bse_song_set_property (GObject *object,
gboolean vbool;
SfiInt vint;
SfiRing *ring;
- case PROP_MUSICAL_TUNING:
- if (!BSE_SOURCE_PREPARED (self))
- {
- self->musical_tuning = (BseMusicalTuningType) g_value_get_enum (value);
- SfiRing *ring;
- for (ring = self->parts; ring; ring = sfi_ring_walk (ring, self->parts))
- bse_part_set_semitone_table ((BsePart*) ring->data, bse_semitone_table_from_tuning
(self->musical_tuning));
- }
- break;
case PROP_PNET:
if (!self->postprocess || !BSE_SOURCE_PREPARED (self->postprocess))
{
@@ -262,9 +252,6 @@ bse_song_get_property (GObject *object,
BseSong *self = BSE_SONG (object);
switch (param_id)
{
- case PROP_MUSICAL_TUNING:
- g_value_set_enum (value, self->musical_tuning);
- break;
case PROP_PNET:
bse_value_set_object (value, self->pnet);
break;
@@ -569,7 +556,7 @@ bse_song_init (BseSong *self)
BSE_OBJECT_UNSET_FLAGS (self, BSE_SNET_FLAG_USER_SYNTH);
BSE_OBJECT_SET_FLAGS (self, BSE_SUPER_FLAG_NEEDS_CONTEXT);
- self->musical_tuning = BSE_MUSICAL_TUNING_12_TET;
+ self->musical_tuning = Bse::MUSICAL_TUNING_12_TET;
self->tpqn = timing.tpqn;
self->numerator = timing.numerator;
@@ -729,16 +716,6 @@ bse_song_class_init (BseSongClass *klass)
bse_song_timing_get_default (&timing);
- bse_object_class_add_param (object_class, _("Tuning"),
- PROP_MUSICAL_TUNING,
- bse_param_spec_enum ("musical_tuning", _("Musical Tuning"),
- _("The tuning system which specifies the tones or pitches
to be used. "
- "Due to the psychoacoustic properties of tones, various
pitch combinations can "
- "sound \"natural\" or \"pleasing\" when used in
combination, the musical "
- "tuning system defines the number and spacing of
frequency values applied."),
- BSE_MUSICAL_TUNING_12_TET, BSE_TYPE_MUSICAL_TUNING_TYPE,
- SFI_PARAM_STANDARD ":unprepared:skip-default"));
-
bse_object_class_add_param (object_class, _("Timing"),
PROP_TPQN,
sfi_pspec_int ("tpqn", _("Ticks"), _("Number of ticks per quarter note"),
@@ -953,4 +930,25 @@ SongImpl::bpm (double val)
// changed ("bpm");
}
+MusicalTuningType
+SongImpl::musical_tuning () const
+{
+ BseSong *self = const_cast<SongImpl*> (this)->as<BseSong*>();
+ return self->musical_tuning;
+}
+
+void
+SongImpl::musical_tuning (MusicalTuningType tuning)
+{
+ BseSong *self = as<BseSong*>();
+ if (!BSE_SOURCE_PREPARED (self))
+ {
+ self->musical_tuning = tuning;
+ SfiRing *ring;
+ for (ring = self->parts; ring; ring = sfi_ring_walk (ring, self->parts))
+ bse_part_set_semitone_table ((BsePart*) ring->data, bse_semitone_table_from_tuning
(self->musical_tuning));
+ // changed ("musical_tuning");
+ }
+}
+
} // Bse
diff --git a/bse/bsesong.hh b/bse/bsesong.hh
index d0d4dba..2b8de24 100644
--- a/bse/bsesong.hh
+++ b/bse/bsesong.hh
@@ -27,7 +27,7 @@ struct BseSong : BseSNet {
guint numerator;
guint denominator;
float bpm;
- BseMusicalTuningType musical_tuning;
+ Bse::MusicalTuningType musical_tuning;
SfiRing *parts; /* of type BsePart* */
SfiRing *busses; /* of type BseBus* */
BseBus *solo_bus;
@@ -74,17 +74,19 @@ class SongImpl : public SNetImpl, public virtual SongIface {
protected:
virtual ~SongImpl ();
public:
- explicit SongImpl (BseObject*);
- virtual double bpm () const override;
- virtual void bpm (double val) override;
- virtual SongTiming get_timing (int tick);
- virtual TrackIfaceP find_any_track_for_part (PartIface &part) override;
- virtual BusIfaceP create_bus () override;
- virtual void remove_bus (BusIface &bus) override;
- virtual PartIfaceP create_part () override;
- virtual void remove_part (PartIface &part) override;
- virtual TrackIfaceP create_track () override;
- virtual void remove_track (TrackIface &track) override;
+ explicit SongImpl (BseObject*);
+ virtual double bpm () const override;
+ virtual void bpm (double val) override;
+ virtual MusicalTuningType musical_tuning () const override;
+ virtual void musical_tuning (MusicalTuningType tuning) override;
+ virtual SongTiming get_timing (int tick);
+ virtual TrackIfaceP find_any_track_for_part (PartIface &part) override;
+ virtual BusIfaceP create_bus () override;
+ virtual void remove_bus (BusIface &bus) override;
+ virtual PartIfaceP create_part () override;
+ virtual void remove_part (PartIface &part) override;
+ virtual TrackIfaceP create_track () override;
+ virtual void remove_track (TrackIface &track) override;
};
} // Bse
diff --git a/bse/bsesource.cc b/bse/bsesource.cc
index 412a9b6..b33f004 100644
--- a/bse/bsesource.cc
+++ b/bse/bsesource.cc
@@ -1909,11 +1909,11 @@ bse_source_class_base_init (BseSourceClass *klass)
klass->automation_properties = NULL;
}
-BseMusicalTuningType
+Bse::MusicalTuningType
bse_source_prepared_musical_tuning (BseSource *source)
{
- assert_return (BSE_IS_SOURCE (source), BSE_MUSICAL_TUNING_12_TET);
- assert_return (BSE_SOURCE_PREPARED (source), BSE_MUSICAL_TUNING_12_TET);
+ assert_return (BSE_IS_SOURCE (source), Bse::MUSICAL_TUNING_12_TET);
+ assert_return (BSE_SOURCE_PREPARED (source), Bse::MUSICAL_TUNING_12_TET);
return bse_item_current_musical_tuning (BSE_ITEM (source)); // FIXME: cache this, once we have
source->SynthesisContext
}
diff --git a/bse/bsesource.hh b/bse/bsesource.hh
index 37559c6..1c01392 100644
--- a/bse/bsesource.hh
+++ b/bse/bsesource.hh
@@ -215,7 +215,7 @@ void bse_source_update_modules (BseSource *source,
BseTrans *trans);
void bse_source_clear_ichannels (BseSource *source);
void bse_source_clear_ochannels (BseSource *source);
-BseMusicalTuningType bse_source_prepared_musical_tuning (BseSource *source);
+Bse::MusicalTuningType bse_source_prepared_musical_tuning (BseSource *source);
/* automation */
typedef struct {
diff --git a/bse/bsetool.cc b/bse/bsetool.cc
index e17603d..b979746 100644
--- a/bse/bsetool.cc
+++ b/bse/bsetool.cc
@@ -187,8 +187,8 @@ dump_info (const ArgParser &ap)
char *string = bse_note_to_string (note);
printout ("%s =%-4d \tfactor=%" FLF "f [%-5s] (freq=%" FLF "f)\n",
note_name, note,
- bse_transpose_factor (BSE_MUSICAL_TUNING_12_TET, note - BSE_KAMMER_NOTE),
- string, bse_note_to_freq (BSE_MUSICAL_TUNING_12_TET, note));
+ bse_transpose_factor (Bse::MUSICAL_TUNING_12_TET, note - BSE_KAMMER_NOTE),
+ string, bse_note_to_freq (Bse::MUSICAL_TUNING_12_TET, note));
g_free (string);
};
auto print_fine_tune = [] (const char *tune_name, int tune) {
@@ -220,13 +220,13 @@ dump_info (const ArgParser &ap)
for (j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j += 3)
for (k = BSE_MIN_FINE_TUNE / 2; k <= BSE_MAX_FINE_TUNE / 2; k += 10)
{
- double f, freq = bse_note_to_tuned_freq (BSE_MUSICAL_TUNING_12_TET, j, k);
+ double f, freq = bse_note_to_tuned_freq (Bse::MUSICAL_TUNING_12_TET, j, k);
int note, fine_tune;
printout ("compose : note=%4d fine_tune=%4d freq=%" FLF "f\n", j, k, freq);
f = freq;
- note = bse_note_from_freq (BSE_MUSICAL_TUNING_12_TET, freq);
- fine_tune = bse_note_fine_tune_from_note_freq (BSE_MUSICAL_TUNING_12_TET, note, freq);
- freq = bse_note_to_tuned_freq (BSE_MUSICAL_TUNING_12_TET, note, fine_tune);
+ note = bse_note_from_freq (Bse::MUSICAL_TUNING_12_TET, freq);
+ fine_tune = bse_note_fine_tune_from_note_freq (Bse::MUSICAL_TUNING_12_TET, note, freq);
+ freq = bse_note_to_tuned_freq (Bse::MUSICAL_TUNING_12_TET, note, fine_tune);
printout ("decompose: note=%4d fine_tune=%4d freq=%" FLF "f (diff=%g)\n", note, fine_tune, freq,
freq - f);
}
if (0)
diff --git a/bse/bseutils.cc b/bse/bseutils.cc
index acefa21..f2f13ef 100644
--- a/bse/bseutils.cc
+++ b/bse/bseutils.cc
@@ -13,42 +13,6 @@
/* --- record utils --- */
-BseNoteDescription*
-bse_note_description (BseMusicalTuningType musical_tuning,
- int note,
- int fine_tune)
-{
- BseNoteDescription *info = bse_note_description_new ();
-
- info->musical_tuning = musical_tuning;
- if (note >= BSE_MIN_NOTE && note <= BSE_MAX_NOTE)
- {
- gchar letter;
- info->note = note;
- gboolean black_semitone = false;
- bse_note_examine (info->note,
- &info->octave,
- &info->semitone,
- &black_semitone,
- &letter);
- info->upshift = black_semitone;
- info->letter = letter;
- info->fine_tune = CLAMP (fine_tune, BSE_MIN_FINE_TUNE, BSE_MAX_FINE_TUNE);
- info->freq = bse_note_to_tuned_freq (musical_tuning, info->note, info->fine_tune);
- info->name = bse_note_to_string (info->note);
- info->max_fine_tune = BSE_MAX_FINE_TUNE;
- info->kammer_note = BSE_KAMMER_NOTE;
- }
- else
- {
- info->note = BSE_NOTE_VOID;
- info->name = NULL;
- info->max_fine_tune = BSE_MAX_FINE_TUNE;
- info->kammer_note = BSE_KAMMER_NOTE;
- }
- return info;
-}
-
Bse::PartNote
bse_part_note (uint id, uint channel, uint tick, uint duration, int note, int fine_tune, double velocity,
bool selected)
{
diff --git a/bse/bseutils.hh b/bse/bseutils.hh
index f43b491..5292863 100644
--- a/bse/bseutils.hh
+++ b/bse/bseutils.hh
@@ -13,9 +13,6 @@ G_BEGIN_DECLS
/* --- C++ helper declaration --- */
void bse_cxx_init (void);
/* --- record utils --- */
-BseNoteDescription* bse_note_description (BseMusicalTuningType musical_tuning,
- int note,
- int fine_tune);
Bse::PartNote bse_part_note (uint id, uint channel, uint tick, uint duration, int note, int fine_tune,
double velocity, bool selected);
Bse::PartControl bse_part_control (uint id, uint tick, Bse::MidiSignalType control_type, double value, bool
selected);
void bse_note_sequence_resize (BseNoteSequence *rec,
diff --git a/bse/tests/misctests.cc b/bse/tests/misctests.cc
index 3f69ca1..fa874c0 100644
--- a/bse/tests/misctests.cc
+++ b/bse/tests/misctests.cc
@@ -42,7 +42,7 @@ static void
check_equal_tempered_tuning (void)
{
TSTART ("Equal Temperament");
- const double *table = bse_semitone_table_from_tuning (BSE_MUSICAL_TUNING_12_TET); /* returns [-132..+132]
*/
+ const double *table = bse_semitone_table_from_tuning (Bse::MUSICAL_TUNING_12_TET); /* returns [-132..+132]
*/
const double epsilon = 1e-11;
for (int i = -132; i <= +132; i++)
{
@@ -55,7 +55,7 @@ check_equal_tempered_tuning (void)
}
static void
-check_tuning_monotony (BseMusicalTuningType musical_tuning)
+check_tuning_monotony (Bse::MusicalTuningType musical_tuning)
{
const double *table = bse_semitone_table_from_tuning (musical_tuning); /* returns [-132..+132] */
for (int i = -132; i <= +132; i++)
@@ -69,7 +69,7 @@ check_tuning_monotony (BseMusicalTuningType musical_tuning)
}
static void
-check_freq_vs_notes (BseMusicalTuningType musical_tuning)
+check_freq_vs_notes (Bse::MusicalTuningType musical_tuning)
{
/* check freq/note mapping */
for (int j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j++)
@@ -92,7 +92,7 @@ check_freq_vs_notes (BseMusicalTuningType musical_tuning)
printout ("decompose: note=%4d fine_tune=%4d freq=%" FLF "f (diff=%" FLF "f)\n", note,
fine_tune, freq, freq - f);
if (ABS (k) < 11)
TASSERT (note == j);
- if (musical_tuning == BSE_MUSICAL_TUNING_12_TET)
+ if (musical_tuning == Bse::MUSICAL_TUNING_12_TET)
TCMP (fabs (freq_error), <, 0.00000000001); /* equal temperament is fairly accurate */
else
TCMP (freq_ratio, <, 1.00057778950655485930); /* detuning should be smaller than a cent */
@@ -133,18 +133,19 @@ main (gint argc,
check_cent_tune();
check_cent_tune_fast();
check_equal_tempered_tuning();
- BseMusicalTuningType last_tuning = BSE_MUSICAL_TUNING_YOUNG;
+ Bse::MusicalTuningType last_tuning = Bse::MUSICAL_TUNING_YOUNG;
/* check last tuning value by asserting defaulting behavior of succeding values */
- TCMP (bse_semitone_table_from_tuning (BseMusicalTuningType (last_tuning + 1)),
+ TCMP (bse_semitone_table_from_tuning (Bse::MusicalTuningType (last_tuning + 1)),
==,
- bse_semitone_table_from_tuning (BseMusicalTuningType (0)));
+ bse_semitone_table_from_tuning (Bse::MusicalTuningType (0)));
/* check monotonic musical tuning systems */
- for (int j = BSE_MUSICAL_TUNING_12_TET; j <= last_tuning; j++)
+ for (int j = Bse::MUSICAL_TUNING_12_TET; j <= last_tuning; j++)
{
- BseMusicalTuningType musical_tuning = BseMusicalTuningType (j);
+ Bse::MusicalTuningType musical_tuning = Bse::MusicalTuningType (j);
check_tuning_monotony (musical_tuning);
check_freq_vs_notes (musical_tuning);
- TPASS ("Tuning System: %s\n", sfi_enum2choice (musical_tuning, BSE_TYPE_MUSICAL_TUNING_TYPE));
+ TPASS ("Tuning System: %s\n",
+ Rapicorn::Aida::enum_info<Bse::MusicalTuningType>().find_value (musical_tuning).ident);
}
return 0;
diff --git a/plugins/bseiirfilter.cc b/plugins/bseiirfilter.cc
index a250475..924b592 100644
--- a/plugins/bseiirfilter.cc
+++ b/plugins/bseiirfilter.cc
@@ -99,7 +99,7 @@ bse_iir_filter_class_init (BseIIRFilterClass *klass)
PARAM_CUT_OFF_NOTE1,
bse_pspec_note ("cut_off_note", _("Note"),
_("Filter cutoff frequency as note, converted to Hertz
according to the current musical tuning"),
- bse_note_from_freq (BSE_MUSICAL_TUNING_12_TET,
BSE_KAMMER_FREQUENCY / 2),
+ bse_note_from_freq (Bse::MUSICAL_TUNING_12_TET,
BSE_KAMMER_FREQUENCY / 2),
SFI_PARAM_GUI));
bse_object_class_add_param (object_class, _("Cutoff Frequency 2 (Band Pass/Stop)"),
PARAM_CUT_OFF_FREQ2,
@@ -110,7 +110,7 @@ bse_iir_filter_class_init (BseIIRFilterClass *klass)
PARAM_CUT_OFF_NOTE2,
bse_pspec_note ("cut_off_note_2", _("Note"),
_("Filter cutoff frequency as note, converted to Hertz
according to the current musical tuning"),
- bse_note_from_freq (BSE_MUSICAL_TUNING_12_TET,
BSE_KAMMER_FREQUENCY / 2 + FREQ_DELTA),
+ bse_note_from_freq (Bse::MUSICAL_TUNING_12_TET,
BSE_KAMMER_FREQUENCY / 2 + FREQ_DELTA),
SFI_PARAM_GUI));
ichannel_id = bse_source_class_add_ichannel (source_class, "audio-in", _("Audio In"), _("Unfiltered
Input"));
diff --git a/plugins/bsesequencer.cc b/plugins/bsesequencer.cc
index 4d9d175..3ba9c4c 100644
--- a/plugins/bsesequencer.cc
+++ b/plugins/bsesequencer.cc
@@ -194,9 +194,7 @@ bse_sequencer_get_property (BseSequencer *seq,
}
static gfloat*
-freq_values_from_seq (BseMusicalTuningType musical_tuning,
- BseNoteSequence *sdata,
- gint transpose)
+freq_values_from_seq (Bse::MusicalTuningType musical_tuning, BseNoteSequence *sdata, int transpose)
{
gfloat *v = g_new (gfloat, bse_note_sequence_length (sdata));
guint i;
diff --git a/plugins/davcanyondelay.cc b/plugins/davcanyondelay.cc
index 3bf7aa5..b9d0719 100644
--- a/plugins/davcanyondelay.cc
+++ b/plugins/davcanyondelay.cc
@@ -88,7 +88,7 @@ dav_canyon_delay_class_init (DavCanyonDelayClass *klass)
bse_object_class_add_param (object_class, _("IIR Low-Pass Filter"), PROP_FILTER_FREQ,
bse_param_spec_freq ("filter_freq", _("Frequency"),
_("Reflection cutoff frequency"),
- bse_note_to_freq (BSE_MUSICAL_TUNING_12_TET, SFI_NOTE_C
(+3)),
+ bse_note_to_freq (Bse::MUSICAL_TUNING_12_TET, SFI_NOTE_C
(+3)),
BSE_MIN_OSC_FREQUENCY, BSE_MAX_OSC_FREQUENCY,
SFI_PARAM_STANDARD ":dial"));
bse_object_class_add_param (object_class, _("IIR Low-Pass Filter"), PROP_FILTER_NOTE,
diff --git a/plugins/davorgan.cc b/plugins/davorgan.cc
index 4b75b12..872c3a7 100644
--- a/plugins/davorgan.cc
+++ b/plugins/davorgan.cc
@@ -86,7 +86,7 @@ class Organ : public OrganBase {
};
/* FIXME: get rid of this as soon as the modules have their own current_musical_tuning() accessor */
struct Properties : public OrganProperties {
- BseMusicalTuningType current_musical_tuning;
+ Bse::MusicalTuningType current_musical_tuning;
Properties (Organ *organ) :
OrganProperties (organ),
current_musical_tuning (organ->current_musical_tuning())
diff --git a/plugins/davsyndrum.cc b/plugins/davsyndrum.cc
index 65d9d9c..7992acf 100644
--- a/plugins/davsyndrum.cc
+++ b/plugins/davsyndrum.cc
@@ -69,7 +69,7 @@ dav_syn_drum_class_init (DavSynDrumClass *klass)
bse_object_class_add_param (object_class, _("Frequency"), PROP_BASE_FREQ,
bse_param_spec_freq ("base_freq", _("Frequency"),
_("Drum frequency in Hertz"),
- bse_note_to_freq (BSE_MUSICAL_TUNING_12_TET, SFI_NOTE_Gis
(-1)),
+ bse_note_to_freq (Bse::MUSICAL_TUNING_12_TET,
SFI_NOTE_Gis (-1)),
BSE_MIN_OSC_FREQUENCY, BSE_MAX_OSC_FREQUENCY,
SFI_PARAM_STANDARD ":dial"));
bse_object_class_add_param (object_class, _("Frequency"), PROP_BASE_NOTE,
diff --git a/tools/bsewavetool.cc b/tools/bsewavetool.cc
index d7e5e52..ede595c 100644
--- a/tools/bsewavetool.cc
+++ b/tools/bsewavetool.cc
@@ -2884,8 +2884,8 @@ public:
if (!note)
{
- note = bse_note_from_freq_bounded (BSE_MUSICAL_TUNING_12_TET, gsl_data_handle_osc_freq
(dhandle));
- cent = bse_note_fine_tune_from_note_freq (BSE_MUSICAL_TUNING_12_TET, note,
gsl_data_handle_osc_freq (dhandle));
+ note = bse_note_from_freq_bounded (Bse::MUSICAL_TUNING_12_TET, gsl_data_handle_osc_freq
(dhandle));
+ cent = bse_note_fine_tune_from_note_freq (Bse::MUSICAL_TUNING_12_TET, note,
gsl_data_handle_osc_freq (dhandle));
}
name_addon = g_strdup_format ("%d", note);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]