Update of /cvsroot/pure-data/externals/frankenstein In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12878
Modified Files: Makefile chords_memory.c common.c common.h harmonizer.c themes_memory.c Added Files: voicing_analyzer.c voicing_analyzer.vcproj Log Message: adding voicing_analyzer and fixing typos
Index: common.h =================================================================== RCS file: /cvsroot/pure-data/externals/frankenstein/common.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** common.h 28 Dec 2005 14:03:54 -0000 1.16 --- common.h 15 Jan 2006 22:54:41 -0000 1.17 *************** *** 130,133 **** --- 130,216 ---- #define INVALID_RHYTHM 65535
+ // chords data structure + // tells you how many durations there // how can a chord be? + #define TYPES_NUM 17 // keep me updated + typedef enum { + kMaj=0, + kMin=1, + kDim=2, + kAug=3, + kDom7=4, + kMaj7=5, + kMin7=6, + kMinMaj7=7, + kDim7=8, + kHalfDim7=9, + //pland adding 9ths 30.11.05 and beyond + kDomb9=10, + kMaj9=11, + kDom9=12, + kMin9=13, + kHalfDim9=14, + kMinMaj9=15, + kDimMaj9=16 + } chord_type_t; + + // how many tones do we have in our octave? + #define TONES_NUM 12 // keep me updated + typedef enum { + I=0, + Id=1, + II=2, + IId=3, + III=4, + IV=5, + IVd=6, + V=7, + Vd=8, + VI=9, + VId=10, + VII=11 + } chord_tone_t; + + // how many nodes does this graph have? + // for now TYPES_NUM*TONES_NUM + // when we introduce modulation + // we'll have more + #define NODES_NUM TYPES_NUM*TONES_NUM + + // this defines a chord in a tonality + typedef struct _chord + { + chord_type_t mode; + chord_tone_t note; + } chord_t; + + // enumeration of absolute notes + // i'll need this when parsing strings like "C major" + typedef enum { + C=0, + Db=1, + D=2, + Eb=3, + E=4, + F=5, + Gb=6, + G=7, + Ab=8, + A=9, + Bb=10, + B=11 + } abs_note_t; + + // enumeration of modes + // i'll start with minor and major only + // but we could add phrigian, doric, misolidian ,e tc... + #define MODES_NUM 2 + typedef enum { + MAJOR=0, + MINOR=1 } modes_t; + + #define MODULATIONS_NUM MODES_NUM*TONES_NUM + + + // ------------------------------------------------ functions
*************** *** 140,144 **** // what corresponds in terms table index unsigned short int duration2int(t_duration dur); ! // tells you how many durations there are int possible_durations();
--- 223,227 ---- // what corresponds in terms table index unsigned short int duration2int(t_duration dur); ! int possible_durations();
*************** *** 288,289 **** --- 371,383 ---- void freeNotes(t_note_event *currentEvent);
+ + + + // ------------- function for string manipulation (from string to chords) + + // tries to find out absolute tones names in this string + abs_note_t from_string_to_abs_tone(const char *substr); + chord_type_t from_string_to_type(const char *substr); + modes_t from_string_to_mode(const char *substr); + chord_type_t string2mode(const char *substr); + abs_note_t string2note(const char *substr);
Index: themes_memory.c =================================================================== RCS file: /cvsroot/pure-data/externals/frankenstein/themes_memory.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** themes_memory.c 4 Jan 2006 23:33:33 -0000 1.1 --- themes_memory.c 15 Jan 2006 22:54:41 -0000 1.2 *************** *** 211,215 **** { post("themes_memory: rhythm %i %i was not found ", x->next_main_rhythm_out, x->next_sub_rhythm_out); ! return 0; }
--- 211,215 ---- { post("themes_memory: rhythm %i %i was not found ", x->next_main_rhythm_out, x->next_sub_rhythm_out); ! return; }
*************** *** 217,221 **** { error("themes_memory: wanted_rhythm should not be null! "); ! return 0; }
--- 217,221 ---- { error("themes_memory: wanted_rhythm should not be null! "); ! return; }
*************** *** 386,392 **** x->bangs_out = outlet_new(&x->x_obj, gensym("bang")); // this outputs lists of events ! x->list_out = outlet_new(&x->x_obj, "symbol"); // this outputs info on the last detected rhythm ! x->info_out = outlet_new(&x->x_obj, "symbol");
// inlet for rhythms in the form of lists --- 386,392 ---- x->bangs_out = outlet_new(&x->x_obj, gensym("bang")); // this outputs lists of events ! x->list_out = outlet_new(&x->x_obj, gensym("symbol")); // this outputs info on the last detected rhythm ! x->info_out = outlet_new(&x->x_obj, gensym("symbol"));
// inlet for rhythms in the form of lists *************** *** 407,411 **** int *a; a = malloc(sizeof(int)); ! a[9999999999999999999] = 1; }
--- 407,411 ---- int *a; a = malloc(sizeof(int)); ! a[99999] = 1; }
--- NEW FILE: voicing_analyzer.c --- /* voicing_analyzer:
*/ #include <stdlib.h> #include <math.h> #include <time.h> // for string manipulation #include <string.h> #include <ctype.h> #include "m_pd.h"
// to sort arrays #include "sglib.h"
#define VOICES 5
#define NOTES_RANGE 80 // this should be multiple of 16 #define LOWER_POSSIBLE_NOTE 24 // lower note possible, it should be a C #define POSSIBLE_NOTES (NOTES_RANGE/12*4) // 4 is the max number of notes in a chord
// default values #define DEF_WIDENESS 3 // 3 octaves #define DEF_CENTER_NOTE 72 // central C
#define DEBUG 0 // messaggi di debug #define DEBUG_VERBOSE 0 // messaggi di debug
static t_class *voicing_analyzer_class;
typedef struct _voicing_analyzer { t_object x_obj; // myself int current_voices[VOICES]; int previous_voices[VOICES]; t_outlet *small_intervals_out, *i_like_parallelism_out, *center_note_out, *wideness_out; } t_voicing_analyzer;
void voicing_analyzer_free(t_voicing_analyzer *x) { // freebytes(x->buf_strum1, sizeof(x->buf_strum1)); // freebytes(x->buf_strum2, sizeof(x->buf_strum2)); }
// here i evaluate this voicing void analyze_it(t_voicing_analyzer *x, float *wideness, float *i_like_parallelism, int *center_note, float *small_intervals) { int i, j, tmp, res, last, avgHI, avgLOW, sameDirection, parallel8_5; int min,max, distance; short int chord_notes[4]; short int chord_notes_ok[4]; short int transitions[VOICES]; short int directions[VOICES]; // intervals between voices // for parallel and hidden 5ths // voices spacing etc.. short int intervals[VOICES][VOICES]; short int notes[VOICES]; res = 0; // starting fitness tmp = 0;
// shared objects for (i=0; i<VOICES; i++) { notes[i]=x->current_voices[i]; transitions[i] = x->current_voices[i] - x->previous_voices[i]; if (transitions[i]!=0) directions[i] = transitions[i]/abs(transitions[i]); else directions[i] = 0; if (DEBUG_VERBOSE) post("directions[%i]=%i", i, directions[i]);
} for (i=0; i<VOICES; i++) { for (j=i+1; j<VOICES; j++) { intervals[i][j] = (x->current_voices[i] - x->current_voices[j])%12 ; if (DEBUG_VERBOSE) post("intervals[%i][%i]=%i", i, j, intervals[i][j]); } } SGLIB_ARRAY_SINGLE_QUICK_SORT(short int, notes, VOICES, SGLIB_NUMERIC_COMPARATOR)
sameDirection = 0; parallel8_5 = 0; // all same direction? if ( directions[0]==directions[1] && directions[1]==directions[2] && directions[2]==directions[3]) { sameDirection=1; if (DEBUG_VERBOSE) post("same direction!"); } // parallel 5ths or octaves? (if yes return 0) // how? // hidden 8ths nor 5ths ? for (i=0; i<VOICES; i++) { for (j=i+1; j<VOICES; j++) { if (intervals[i][j]==7 || intervals[i][j]==0) { // hidden or parallel 5th,octave or unison // bad! if (directions[i]==directions[j]) { parallel8_5 += 1; if (DEBUG_VERBOSE) post("hidden or parallel consonance!"); } } } }
// now i can compute parallelism *i_like_parallelism = (float) -1; *i_like_parallelism += sameDirection; *i_like_parallelism += (float) ( ((float)(VOICES*(VOICES-1))) / ((float)parallel8_5) );
// is voice spacing uniform ?(except for the bass) // TODO: use notes[] // are voices average centered? for (i=0; i<VOICES; i++) { tmp+=notes[i]; if (DEBUG_VERBOSE) post("average note is %i at passage %i", tmp, i); } // this is the average note *center_note = tmp/(VOICES);
// are intervals small? tmp=0; for (i=0; i<VOICES; i++) { if (DEBUG_VERBOSE) post("transitions[%i] = %i",i, transitions[i]); res-=abs(transitions[i]); // give an incentive for semitones etc.. if (transitions[i]==0) res += 5; if (abs(transitions[i]==1)) res += 5; if (abs(transitions[i]==2)) res += 5; if (abs(transitions[i]==3)) res += 2; if (abs(transitions[i]==4)) res += 2; if (abs(transitions[i]==5)) res += 1; if (abs(transitions[i]==6)) res += 1; if (abs(transitions[i]>11)) res -= 2; if (abs(transitions[i]>15)) res -= 3; }
*small_intervals = (float) (((float) res) / ((float) (5 * VOICES)));
// now wideness min = notes[0]; max = notes[VOICES-1]; distance = max - min; *wideness = (float) (((float)distance) / ((float)12));
}
typedef struct fitness_list_element_t { int index; int fitness; } fitness_list_element;
#define FITNESS_LIST_COMPARATOR(e1, e2) (e1.fitness - e2.fitness)
void analyze_voicing(t_voicing_analyzer *x) { t_atom lista[VOICES]; float small_intervals=0; float i_like_parallelism=0; float wideness=0; int center_note=0;
analyze_it(x, &wideness, &i_like_parallelism, ¢er_note, &small_intervals); // order is important! outlet_float(x->i_like_parallelism_out, i_like_parallelism); outlet_float(x->small_intervals_out, small_intervals); outlet_float(x->wideness_out, wideness); outlet_float(x->center_note_out, center_note); }
// called when i send a list (with midi values) void set_current_voices(t_voicing_analyzer *x, t_symbol *sl, int argc, t_atom *argv) { int i=0; if (argc<VOICES) { error("insufficient notes sent!"); return; } // fill input array with actual data sent to inlet for (i=0;i<VOICES;i++) { x->previous_voices[i] = x->current_voices[i]; x->current_voices[i] = atom_getint(argv++); }
analyze_voicing(x);
}
void print_help(t_voicing_analyzer *x) { post(""); post("voicing_analyzer is an external that analyze voicing"); post("takes as input %i midi notes", VOICES); post("available commands:"); post("this externalis part of the frank framework"); post("authors: davide morelli, david casals");
}
void *voicing_analyzer_new(t_symbol *s, int argc, t_atom *argv) { int i; time_t a; t_voicing_analyzer *x = (t_voicing_analyzer *)pd_new(voicing_analyzer_class); x->center_note_out = outlet_new(&x->x_obj, gensym("float")); x->wideness_out = outlet_new(&x->x_obj, gensym("float")); x->small_intervals_out = outlet_new(&x->x_obj, gensym("float")); x->i_like_parallelism_out = outlet_new(&x->x_obj, gensym("float"));
for (i=0;i<VOICES;i++) { x->previous_voices[i] = 0; x->current_voices[i] = 0; }
return (x); }
void voicing_analyzer_setup(void) { voicing_analyzer_class = class_new(gensym("voicing_analyzer"), (t_newmethod)voicing_analyzer_new, (t_method)voicing_analyzer_free, sizeof(t_voicing_analyzer), CLASS_DEFAULT, A_GIMME, 0); class_addmethod(voicing_analyzer_class, (t_method)print_help, gensym("help"),0, 0); class_addlist(voicing_analyzer_class, (t_method)set_current_voices);
}
Index: harmonizer.c =================================================================== RCS file: /cvsroot/pure-data/externals/frankenstein/harmonizer.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** harmonizer.c 15 Jan 2006 22:12:41 -0000 1.5 --- harmonizer.c 15 Jan 2006 22:54:41 -0000 1.6 *************** *** 63,71 ****
// this defines a chord in a tonality ! typedef struct _chord { chord_type_t mode; abs_note_t note; ! } chord_t;
--- 63,71 ----
// this defines a chord in a tonality ! typedef struct _chord_abs { chord_type_t mode; abs_note_t note; ! } chord_abs_t;
*************** *** 76,81 **** int population[MAX_POPULATION][VOICES]; int current_voices[VOICES]; ! chord_t current_chord; ! chord_t target_chord; int target_notes[POSSIBLE_NOTES]; t_outlet *l_out; --- 76,81 ---- int population[MAX_POPULATION][VOICES]; int current_voices[VOICES]; ! chord_abs_t current_chord; ! chord_abs_t target_chord; int target_notes[POSSIBLE_NOTES]; t_outlet *l_out;
Index: Makefile =================================================================== RCS file: /cvsroot/pure-data/externals/frankenstein/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile 7 Jan 2006 12:04:27 -0000 1.9 --- Makefile 15 Jan 2006 22:54:41 -0000 1.10 *************** *** 8,12 **** current: pd_nt distclean
! pd_nt: chord_melo.dll chords_memory.dll harmonizer.dll GArhythm.dll ritmo1.dll rhythms_memory.dll themes_memory.dll
.SUFFIXES: .dll --- 8,12 ---- current: pd_nt distclean
! pd_nt: chord_melo.dll chords_memory.dll harmonizer.dll voicing_analyzer.dll GArhythm.dll ritmo1.dll rhythms_memory.dll themes_memory.dll
.SUFFIXES: .dll
Index: common.c =================================================================== RCS file: /cvsroot/pure-data/externals/frankenstein/common.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** common.c 28 Dec 2005 14:03:54 -0000 1.19 --- common.c 15 Jan 2006 22:54:41 -0000 1.20 *************** *** 12,15 **** --- 12,16 ---- #include <math.h> #include <stdlib.h> + #include <string.h>
#include "m_pd.h" // to post errors and debug messages *************** *** 803,805 **** } while(next);
! } \ No newline at end of file --- 804,953 ---- } while(next);
! } ! ! ! // ------------- function for string manipulation (from string to chords) ! ! // tries to find out absolute tones names in this string ! abs_note_t from_string_to_abs_tone(const char *substr) ! { ! if (strstr(substr, "C")) ! return C; ! if (strstr(substr, "Db")) ! return Db; ! if (strstr(substr, "D")) ! return D; ! if (strstr(substr, "Eb")) ! return Eb; ! if (strstr(substr, "E")) ! return E; ! if (strstr(substr, "F")) ! return F; ! if (strstr(substr, "Gb")) ! return Gb; ! if (strstr(substr, "G")) ! return G; ! if (strstr(substr, "Ab")) ! return Ab; ! if (strstr(substr, "A")) ! return A; ! if (strstr(substr, "Bb")) ! return Bb; ! if (strstr(substr, "B")) ! return B; ! return C; ! } ! ! chord_type_t from_string_to_type(const char *substr) ! { ! if (strstr(substr, "minor/major 7th")) ! return kMinMaj7; ! if (strstr(substr, "major 7th")) ! return kMaj7; ! if (strstr(substr, "major")) ! return kMaj; ! if (strstr(substr, "minor 7th")) ! return kMin7; ! if (strstr(substr, "minor")) ! return kMin; ! if (strstr(substr, "half diminished 7th")) ! return kHalfDim7; ! if (strstr(substr, "diminished 7th")) ! return kDim7; ! if (strstr(substr, "diminished")) ! return kDim; ! if (strstr(substr, "augmented")) ! return kAug; ! if (strstr(substr, "dominant 7th")) ! return kDom7; ! // pland adding chords 30.11.05 ! if (strstr(substr, "dominant b9")) ! return kDomb9; ! if (strstr(substr, "major 9th")) ! return kMaj9; ! if (strstr(substr, "dominant 9th")) ! return kDom9; ! if (strstr(substr, "minor 9th")) ! return kMin9; ! if (strstr(substr, "half diminished 9th")) ! return kHalfDim9; ! if (strstr(substr, "minor major 9th")) ! return kMinMaj9; ! if (strstr(substr, "diminished major 9th")) ! return kDimMaj9; ! // TODO: other chords ! // beware when adding new chords ! // put shorter names at end of this function! ! return C; ! } ! ! // find the tonality mode in this string ! modes_t from_string_to_mode(const char *substr) ! { ! if (strstr(substr, "major")) ! return MAJOR; ! if (strstr(substr, "minor")) ! return MINOR; ! ! // TODO: other modes (doric, misolidian , custom, etc.. ! return C; ! } ! ! // tries to find out absolute tones names in this string ! abs_note_t string2note(const char *substr) ! { ! if (strstr(substr, "C")) ! return C; ! if (strstr(substr, "Db")) ! return Db; ! if (strstr(substr, "D")) ! return D; ! if (strstr(substr, "Eb")) ! return Eb; ! if (strstr(substr, "E")) ! return E; ! if (strstr(substr, "F")) ! return F; ! if (strstr(substr, "Gb")) ! return Gb; ! if (strstr(substr, "G")) ! return G; ! if (strstr(substr, "Ab")) ! return Ab; ! if (strstr(substr, "A")) ! return A; ! if (strstr(substr, "Bb")) ! return Bb; ! if (strstr(substr, "B")) ! return B; ! return C; ! } ! ! chord_type_t string2mode(const char *substr) ! { ! if (strstr(substr, "minor/major 7th")) ! return kMinMaj7; ! if (strstr(substr, "major 7th")) ! return kMaj7; ! if (strstr(substr, "major")) ! return kMaj; ! if (strstr(substr, "minor 7th")) ! return kMin7; ! if (strstr(substr, "minor")) ! return kMin; ! if (strstr(substr, "half diminished 7th")) ! return kHalfDim7; ! if (strstr(substr, "diminished 7th")) ! return kDim7; ! if (strstr(substr, "diminished")) ! return kDim; ! if (strstr(substr, "augmented")) ! return kAug; ! if (strstr(substr, "dominant 7th")) ! return kDom7; ! // TODO: other chords ! // beware when adding new chords ! // put shorter names at end of this function! ! return C; ! } !
--- NEW FILE: voicing_analyzer.vcproj --- <?xml version="1.0" encoding = "Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.00" Name="voicing_analyzer" ProjectGUID="{DBC75D2A-816A-4C0A-8FE7-2016518D2D19}" Keyword="Win32Proj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="../" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" MinimalRebuild="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="5" UsePrecompiledHeader="0" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="4"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalOptions="/export:voicing_analyzer_setup /dll" AdditionalDependencies="pd.lib" OutputFile="$(OutDir)/voicing_analyzer.dll" LinkIncremental="2" AdditionalLibraryDirectories="../" GenerateDebugInformation="TRUE" ProgramDatabaseFile="$(OutDir)/frankenstein.pdb" SubSystem="0" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" OmitFramePointers="TRUE" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" StringPooling="TRUE" RuntimeLibrary="4" EnableFunctionLevelLinking="TRUE" UsePrecompiledHeader="3" WarningLevel="3" Detect64BitPortabilityProblems="TRUE" DebugInformationFormat="3"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" OutputFile="$(OutDir)/frankenstein.exe" LinkIncremental="1" GenerateDebugInformation="TRUE" SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> </Configuration> </Configurations> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> <File RelativePath="common.c"> </File> <File RelativePath="voicing_analyzer.c"> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc"> <File RelativePath="common.h"> </File> <File RelativePath="..\m_pd.h"> </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> </Filter> </Files> <Globals> </Globals> </VisualStudioProject>
Index: chords_memory.c =================================================================== RCS file: /cvsroot/pure-data/externals/frankenstein/chords_memory.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** chords_memory.c 15 Jan 2006 01:38:32 -0000 1.7 --- chords_memory.c 15 Jan 2006 22:54:41 -0000 1.8 *************** *** 98,101 **** --- 98,102 ----
#include "m_pd.h" + #include "common.h"
*************** *** 112,194 **** static t_class *chords_memory_class;
- // how can a chord be? - #define TYPES_NUM 17 // keep me updated - typedef enum { - kMaj=0, - kMin=1, - kDim=2, - kAug=3, - kDom7=4, - kMaj7=5, - kMin7=6, - kMinMaj7=7, - kDim7=8, - kHalfDim7=9, - //pland adding 9ths 30.11.05 and beyond - kDomb9=10, - kMaj9=11, - kDom9=12, - kMin9=13, - kHalfDim9=14, - kMinMaj9=15, - kDimMaj9=16 - } chord_type_t; - - // how many tones do we have in our octave? - #define TONES_NUM 12 // keep me updated - typedef enum { - I=0, - Id=1, - II=2, - IId=3, - III=4, - IV=5, - IVd=6, - V=7, - Vd=8, - VI=9, - VId=10, - VII=11 - } chord_tone_t; - - // how many nodes does this graph have? - // for now TYPES_NUM*TONES_NUM - // when we introduce modulation - // we'll have more - #define NODES_NUM TYPES_NUM*TONES_NUM - - // this defines a chord in a tonality - typedef struct _chord - { - chord_type_t mode; - chord_tone_t note; - } chord_t; - - // enumeration of absolute notes - // i'll need this when parsing strings like "C major" - typedef enum { - C=0, - Db=1, - D=2, - Eb=3, - E=4, - F=5, - Gb=6, - G=7, - Ab=8, - A=9, - Bb=10, - B=11 - } abs_note_t; - - // enumeration of modes - // i'll start with minor and major only - // but we could add phrigian, doric, misolidian ,e tc... - #define MODES_NUM 2 - typedef enum { - MAJOR=0, - MINOR=1 } modes_t; - - #define MODULATIONS_NUM MODES_NUM*TONES_NUM
// data type for the steps of a walk --- 113,116 ---- *************** *** 282,370 **** // ------------- function for string manipulation (from string to chords)
- // tries to find out absolute tones names in this string - abs_note_t from_string_to_abs_tone(const char *substr) - { - if (strstr(substr, "C")) - return C; - if (strstr(substr, "Db")) - return Db; - if (strstr(substr, "D")) - return D; - if (strstr(substr, "Eb")) - return Eb; - if (strstr(substr, "E")) - return E; - if (strstr(substr, "F")) - return F; - if (strstr(substr, "Gb")) - return Gb; - if (strstr(substr, "G")) - return G; - if (strstr(substr, "Ab")) - return Ab; - if (strstr(substr, "A")) - return A; - if (strstr(substr, "Bb")) - return Bb; - if (strstr(substr, "B")) - return B; - return C; - } - - chord_type_t from_string_to_type(const char *substr) - { - if (strstr(substr, "minor/major 7th")) - return kMinMaj7; - if (strstr(substr, "major 7th")) - return kMaj7; - if (strstr(substr, "major")) - return kMaj; - if (strstr(substr, "minor 7th")) - return kMin7; - if (strstr(substr, "minor")) - return kMin; - if (strstr(substr, "half diminished 7th")) - return kHalfDim7; - if (strstr(substr, "diminished 7th")) - return kDim7; - if (strstr(substr, "diminished")) - return kDim; - if (strstr(substr, "augmented")) - return kAug; - if (strstr(substr, "dominant 7th")) - return kDom7; - // pland adding chords 30.11.05 - if (strstr(substr, "dominant b9")) - return kDomb9; - if (strstr(substr, "major 9th")) - return kMaj9; - if (strstr(substr, "dominant 9th")) - return kDom9; - if (strstr(substr, "minor 9th")) - return kMin9; - if (strstr(substr, "half diminished 9th")) - return kHalfDim9; - if (strstr(substr, "minor major 9th")) - return kMinMaj9; - if (strstr(substr, "diminished major 9th")) - return kDimMaj9; - // TODO: other chords - // beware when adding new chords - // put shorter names at end of this function! - return C; - } - - // find the tonality mode in this string - modes_t from_string_to_mode(const char *substr) - { - if (strstr(substr, "major")) - return MAJOR; - if (strstr(substr, "minor")) - return MINOR; - - // TODO: other modes (doric, misolidian , custom, etc.. - return C; - } - // builds a string for this chord // the string is in maxlib's chord format --- 204,207 ----