1 // Copyright 2004 "Gilles Degottex"
3 // This file is part of "Music"
5 // "Music" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 2.1 of the License, or
8 // (at your option) any later version.
10 // "Music" is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 Music::NotesName Music::s_notes_name = Music::LOCAL_ANGLO;
27 int Music::s_tonality = 0;
28 int Music::s_sampling_rate = -1;
29 double Music::s_AFreq = 440.0;
30 const int Music::UNDEFINED_SEMITONE = -1000;
31 int Music::s_semitone_min = -48;
32 int Music::s_semitone_max = +48;
34 Music::SettingsListener::SettingsListener()
36 s_settings_listeners.push_back(this);
38 Music::SettingsListener::~SettingsListener()
40 s_settings_listeners.remove(this);
43 list<Music::SettingsListener*> Music::s_settings_listeners;
44 void Music::AddSettingsListener(SettingsListener* l)
46 if(find(s_settings_listeners.begin(), s_settings_listeners.end(), l)==s_settings_listeners.end())
47 s_settings_listeners.push_back(l);
49 void Music::RemoveSettingsListener(SettingsListener* l)
51 s_settings_listeners.remove(l);
54 void Music::SetSamplingRate(int sampling_rate)
56 s_sampling_rate = sampling_rate;
57 for(list<Music::SettingsListener*>::iterator it=s_settings_listeners.begin(); it!=s_settings_listeners.end(); ++it)
58 (*it)->samplingRateChanged();
61 void Music::SetAFreq(double AFreq)
64 for(list<Music::SettingsListener*>::iterator it=s_settings_listeners.begin(); it!=s_settings_listeners.end(); ++it)
65 (*it)->AFreqChanged();
68 void Music::SetSemitoneBounds(int semitone_min, int semitone_max)
70 // cerr << "Music::SetSemitoneBounds" << endl;
72 s_semitone_min = semitone_min;
73 s_semitone_max = semitone_max;
75 for(list<Music::SettingsListener*>::iterator it=s_settings_listeners.begin(); it!=s_settings_listeners.end(); ++it)
76 (*it)->semitoneBoundsChanged();
79 vector<double> Music::conv(const vector<double>& u, const vector<double>& v)
81 vector<double> w(v.size());
83 for(size_t i=0; i<w.size(); i++)
86 for(size_t j=0; j<u.size(); j++)