|
From: <pst...@us...> - 2008-04-11 02:25:23
|
Revision: 452
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=452&view=rev
Author: pstieber
Date: 2008-04-10 19:25:18 -0700 (Thu, 10 Apr 2008)
Log Message:
-----------
Made some style and cosmetic changes.
Modified Paths:
--------------
trunk/jazz/src/AlsaDriver.cpp
trunk/jazz/src/Configuration.cpp
trunk/jazz/src/Configuration.h
trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp
trunk/jazz/src/Dialogs.cpp
trunk/jazz/src/Globals.cpp
trunk/jazz/src/Globals.h
trunk/jazz/src/PianoWindow.cpp
trunk/jazz/src/Project.cpp
trunk/jazz/src/Project.h
trunk/jazz/src/Rhythm.cpp
trunk/jazz/src/Track.cpp
Modified: trunk/jazz/src/AlsaDriver.cpp
===================================================================
--- trunk/jazz/src/AlsaDriver.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/AlsaDriver.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -134,8 +134,8 @@
pcm[PLAYBACK] = NULL;
pcm[CAPTURE] = NULL;
- dev[PLAYBACK] = gpConfig->StrValue(C_AlsaAudioOutputDevice);
- dev[CAPTURE] = gpConfig->StrValue(C_AlsaAudioInputDevice);
+ dev[PLAYBACK] = gpConfig->GetStrValue(C_AlsaAudioOutputDevice);
+ dev[CAPTURE] = gpConfig->GetStrValue(C_AlsaAudioInputDevice);
// FIXME
mCanDuplex = 1;
Modified: trunk/jazz/src/Configuration.cpp
===================================================================
--- trunk/jazz/src/Configuration.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Configuration.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -34,76 +34,92 @@
using namespace std;
-tConfigEntry::tConfigEntry(const char* pName, int IntegerValue)
- : Type(ConfigEntryTypeInt),
- Name(0),
- Value(IntegerValue),
- StrValue(0)
+//*****************************************************************************
+// Description:
+// This is the configuration entry class definition.
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfigEntry::JZConfigEntry(const char* pName, int IntegerValue)
+ : mType(ConfigEntryTypeInt),
+ mName(0),
+ mValue(IntegerValue),
+ mStrValue(0)
{
if (pName)
{
- Name = new char [strlen(pName) + 1];
- strcpy(Name, pName);
+ mName = new char [strlen(pName) + 1];
+ strcpy(mName, pName);
}
}
-tConfigEntry::tConfigEntry(const char* pName, const char* pStringValue)
- : Type(ConfigEntryTypeStr),
- Name(0),
- Value(0),
- StrValue(0)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfigEntry::JZConfigEntry(const char* pName, const char* pStringValue)
+ : mType(ConfigEntryTypeStr),
+ mName(0),
+ mValue(0),
+ mStrValue(0)
{
if (pName)
{
- Name = new char [strlen(pName) + 1];
- strcpy(Name, pName);
+ mName = new char [strlen(pName) + 1];
+ strcpy(mName, pName);
}
if (pStringValue)
{
- StrValue = new char[strlen(pStringValue) + 1];
- strcpy(StrValue, pStringValue);
+ mStrValue = new char[strlen(pStringValue) + 1];
+ strcpy(mStrValue, pStringValue);
}
}
-tConfigEntry::tConfigEntry(const char* pName, const string& StringValue)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfigEntry::JZConfigEntry(const char* pName, const string& StringValue)
{
if (pName)
{
- Name = new char [strlen(pName) + 1];
- strcpy(Name, pName);
+ mName = new char [strlen(pName) + 1];
+ strcpy(mName, pName);
}
- StrValue = new char[strlen(StringValue.c_str()) + 1];
- strcpy(StrValue, StringValue.c_str());
+ mStrValue = new char[strlen(StringValue.c_str()) + 1];
+ strcpy(mStrValue, StringValue.c_str());
}
-tConfigEntry::tConfigEntry(const char* pName)
- : Type(ConfigEntryTypeEmpty),
- Name(0),
- Value(0),
- StrValue(0)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfigEntry::JZConfigEntry(const char* pName)
+ : mType(ConfigEntryTypeEmpty),
+ mName(0),
+ mValue(0),
+ mStrValue(0)
{
if (pName)
{
- Name = new char [strlen(pName) + 1];
- strcpy(Name, pName);
+ mName = new char [strlen(pName) + 1];
+ strcpy(mName, pName);
}
}
-tConfigEntry::~tConfigEntry()
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfigEntry::~JZConfigEntry()
{
- delete [] Name;
- delete [] StrValue;
+ delete [] mName;
+ delete [] mStrValue;
}
-void tConfigEntry::SetStrValue(const char* pStringValue)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZConfigEntry::SetStrValue(const char* pStringValue)
{
- delete [] StrValue;
+ delete [] mStrValue;
if (pStringValue)
{
- StrValue = new char[strlen(pStringValue) + 1];
- strcpy(StrValue, pStringValue);
+ mStrValue = new char[strlen(pStringValue) + 1];
+ strcpy(mStrValue, pStringValue);
}
}
@@ -113,7 +129,13 @@
-tConfig::tConfig()
+//*****************************************************************************
+// Description:
+// This is the configuration class definition.
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfiguration::JZConfiguration()
: mFileName(),
mDrumNames(),
mDrumSets(),
@@ -123,142 +145,158 @@
{
for (int i = 0; i < NumConfigNames; ++i)
{
- Names[i] = 0;
+ mNames[i] = 0;
}
const char* pNoneString = "None";
// search for midi device
- Names[C_Seq2Device] = new tConfigEntry(".device", -1);
+ mNames[C_Seq2Device] = new JZConfigEntry(".device", -1);
// use /dev/music
- Names[C_MidiDriver] = new tConfigEntry(".driver", 1);
+ mNames[C_MidiDriver] = new JZConfigEntry(".driver", 1);
- // Enable audio at startup
- Names[C_EnableAudio] = new tConfigEntry(".enable_audio", 1);
+ // Enable audio at startup.
+ mNames[C_EnableAudio] = new JZConfigEntry(".enable_audio", 1);
- // Windows midi devices
- Names[C_WinInputDevice] = new tConfigEntry(".win_input_device", -1);
- Names[C_WinOutputDevice] = new tConfigEntry(".win_output_device", -1);
+ // Windows midi devices.
+ mNames[C_WinInputDevice] = new JZConfigEntry(".win_input_device", -1);
+ mNames[C_WinOutputDevice] = new JZConfigEntry(".win_output_device", -1);
- // ALSA midi devices
- Names[C_AlsaInputDevice] = new tConfigEntry(".alsa_input_device", -1);
- Names[C_AlsaOutputDevice] = new tConfigEntry(".alsa_output_device", -1);
+ // ALSA midi devices.
+ mNames[C_AlsaInputDevice] = new JZConfigEntry(".alsa_input_device", -1);
+ mNames[C_AlsaOutputDevice] = new JZConfigEntry(".alsa_output_device", -1);
- // ALSA audio devices
- Names[C_AlsaAudioInputDevice] = new tConfigEntry(".alsa_audio_input_device", "hw:0,0");
- Names[C_AlsaAudioOutputDevice] = new tConfigEntry(".alsa_audio_output_device", "hw:0,0");
+ // ALSA audio devices.
+ mNames[C_AlsaAudioInputDevice] = new JZConfigEntry(
+ ".alsa_audio_input_device",
+ "hw:0,0");
+ mNames[C_AlsaAudioOutputDevice] = new JZConfigEntry(
+ ".alsa_audio_output_device",
+ "hw:0,0");
- // emulate midi thru
- Names[C_SoftThru] = new tConfigEntry(".softthru", 1);
+ // Emulate MIDI thru.
+ mNames[C_SoftThru] = new JZConfigEntry(".softthru", 1);
- // mpu401 hardware midi thru
- Names[C_HardThru] = new tConfigEntry(".hardthru", 1);
+ // mpu401 hardware MIDI thru.
+ mNames[C_HardThru] = new JZConfigEntry(".hardthru", 1);
- // midi clock source (0 = internal)
- Names[C_ClockSource] = new tConfigEntry(".clocksource", 0);
+ // MIDI clock source (0 = internal).
+ mNames[C_ClockSource] = new JZConfigEntry(".clocksource", 0);
- // send realtime midi messages to midi out
- Names[C_RealTimeOut] = new tConfigEntry(".realtime_out", 0);
+ // Send realtime MIDI messages to MIDI out.
+ mNames[C_RealTimeOut] = new JZConfigEntry(".realtime_out", 0);
- // use GS reverb macro
- Names[C_UseReverbMacro] = new tConfigEntry(".use_reverb_macro", 1);
+ // Use the GS reverb macro.
+ mNames[C_UseReverbMacro] = new JZConfigEntry(".use_reverb_macro", 1);
- // use GS chorus macro
- Names[C_UseChorusMacro] = new tConfigEntry(".use_chorus_macro", 1);
+ // Use the GS chorus macro.
+ mNames[C_UseChorusMacro] = new JZConfigEntry(".use_chorus_macro", 1);
- // Default drum channel is 10
- Names[C_DrumChannel] = new tConfigEntry(".drumchannel", 10);
+ // Default drum channel is 10.
+ mNames[C_DrumChannel] = new JZConfigEntry(".drumchannel", 10);
- // Controller for bank select
- Names[C_BankControlNumber] = new tConfigEntry(".bank_control_number", 0);
+ // Controller for bank select.
+ mNames[C_BankControlNumber] = new JZConfigEntry(".bank_control_number", 0);
- // Controller2 for bank select with two commands
- Names[C_BankControlNumber2] = new tConfigEntry(".bank_2nd_control_number", 32);
+ // Controller2 for bank select with two commands.
+ mNames[C_BankControlNumber2] = new JZConfigEntry(
+ ".bank_2nd_control_number",
+ 32);
- // Max number of entries in bank table (two commands)
- Names[C_MaxBankTableEntries] = new tConfigEntry(".max_bank_table_entries", 256);
+ // Maximum number of entries in bank table (two commands).
+ mNames[C_MaxBankTableEntries] = new JZConfigEntry(
+ ".max_bank_table_entries",
+ 256);
- // Number of columns to draw in Parts dialogs
- Names[C_PartsColumnsMax] = new tConfigEntry(".parts_columns_max", 4);
+ // Number of columns to draw in Parts dialogs.
+ mNames[C_PartsColumnsMax] = new JZConfigEntry(".parts_columns_max", 4);
// Draw tracknames on the right too?
- Names[C_PartsTracknamesRight] = new tConfigEntry(
+ mNames[C_PartsTracknamesRight] = new JZConfigEntry(
".parts_tracknames_right",
1);
- // Maximum number of voice names in .jazz
- Names[C_MaxVoiceNames] = new tConfigEntry(".max_voice_names", 317);
+ // Maximum number of voice names in .jazz.
+ mNames[C_MaxVoiceNames] = new JZConfigEntry(".max_voice_names", 317);
// Use two-command bank select?
- Names[C_UseTwoCommandBankSelect] = new tConfigEntry(
+ mNames[C_UseTwoCommandBankSelect] = new JZConfigEntry(
".use_two_command_bank_select",
0);
- // Metronome settings
- Names[C_MetroIsAccented] = new tConfigEntry(".metronome_is_accented", 1);
- Names[C_MetroVelocity] = new tConfigEntry(".metronome_velocity", 127);
- Names[C_MetroNormalClick] = new tConfigEntry(".metronome_normal_click", 37);
- Names[C_MetroAccentedClick] = new tConfigEntry(
+ // Metronome settings.
+ mNames[C_MetroIsAccented] = new JZConfigEntry(
+ ".metronome_is_accented",
+ 1);
+ mNames[C_MetroVelocity] = new JZConfigEntry(
+ ".metronome_velocity",
+ 127);
+ mNames[C_MetroNormalClick] = new JZConfigEntry(
+ ".metronome_normal_click",
+ 37);
+ mNames[C_MetroAccentedClick] = new JZConfigEntry(
".metronome_accented_click",
36);
// Window geometry settings.
- Names[C_TrackWinXpos] = new tConfigEntry(".trackwin_xpos", 10);
- Names[C_TrackWinYpos] = new tConfigEntry(".trackwin_ypos", 10);
- Names[C_TrackWinWidth] = new tConfigEntry(".trackwin_width", 600);
- Names[C_TrackWinHeight] = new tConfigEntry(".trackwin_height", 400);
- Names[C_PianoWinXpos] = new tConfigEntry(".pianowin_xpos", 30);
- Names[C_PianoWinYpos] = new tConfigEntry(".pianowin_ypos", 30);
- Names[C_PianoWinWidth] = new tConfigEntry(".pianowin_width", 600);
- Names[C_PianoWinHeight] = new tConfigEntry(".pianowin_height", 400);
- Names[C_PartsDlgXpos] = new tConfigEntry(".partsdialog_xpos", 50);
- Names[C_PartsDlgYpos] = new tConfigEntry(".partsdialog_ypos", 50);
- Names[C_TrackDlgXpos] = new tConfigEntry(".trackdialog_xpos", 50);
- Names[C_TrackDlgYpos] = new tConfigEntry(".trackdialog_ypos", 50);
- Names[C_HarmonyXpos] = new tConfigEntry(".harmonybrowser_xpos", 100);
- Names[C_HarmonyYpos] = new tConfigEntry(".harmonybrowser_ypos", 100);
- Names[C_RhythmXpos] = new tConfigEntry(".randomrhythm_xpos", 150);
- Names[C_RhythmYpos] = new tConfigEntry(".randomrhythm_ypos", 150);
+ mNames[C_TrackWinXpos] = new JZConfigEntry(".trackwin_xpos", 10);
+ mNames[C_TrackWinYpos] = new JZConfigEntry(".trackwin_ypos", 10);
+ mNames[C_TrackWinWidth] = new JZConfigEntry(".trackwin_width", 600);
+ mNames[C_TrackWinHeight] = new JZConfigEntry(".trackwin_height", 400);
+ mNames[C_PianoWinXpos] = new JZConfigEntry(".pianowin_xpos", 30);
+ mNames[C_PianoWinYpos] = new JZConfigEntry(".pianowin_ypos", 30);
+ mNames[C_PianoWinWidth] = new JZConfigEntry(".pianowin_width", 600);
+ mNames[C_PianoWinHeight] = new JZConfigEntry(".pianowin_height", 400);
+ mNames[C_PartsDlgXpos] = new JZConfigEntry(".partsdialog_xpos", 50);
+ mNames[C_PartsDlgYpos] = new JZConfigEntry(".partsdialog_ypos", 50);
+ mNames[C_TrackDlgXpos] = new JZConfigEntry(".trackdialog_xpos", 50);
+ mNames[C_TrackDlgYpos] = new JZConfigEntry(".trackdialog_ypos", 50);
+ mNames[C_HarmonyXpos] = new JZConfigEntry(".harmonybrowser_xpos", 100);
+ mNames[C_HarmonyYpos] = new JZConfigEntry(".harmonybrowser_ypos", 100);
+ mNames[C_RhythmXpos] = new JZConfigEntry(".randomrhythm_xpos", 150);
+ mNames[C_RhythmYpos] = new JZConfigEntry(".randomrhythm_ypos", 150);
- // Show Dialog unless initialized
- Names[C_SynthDialog] = new tConfigEntry(".synth_dialog", 1);
+ // Show dialog unless initialized.
+ mNames[C_SynthDialog] = new JZConfigEntry(".synth_dialog", 1);
- // Default synthesizer type
- Names[C_SynthType] = new tConfigEntry(
+ // Default synthesizer type.
+ mNames[C_SynthType] = new JZConfigEntry(
".synth_type",
gSynthesizerTypes[SynthTypeGS].first.c_str());
- // Default synthesizer config file
- Names[C_SynthConfig] = new tConfigEntry(
+ // Default synthesizer configuration file.
+ mNames[C_SynthConfig] = new JZConfigEntry(
".synth_config",
gSynthesierTypeFiles[SynthTypeGS].first.c_str());
- // When to send synthesizer reset (0=never, 1=song start, 2=start play)
- Names[C_SendSynthReset] = new tConfigEntry(".send_synth_reset", 1);
+ // When to send synthesizer reset (0 = never, 1 = song start,
+ // 2 = start play).
+ mNames[C_SendSynthReset] = new JZConfigEntry(".send_synth_reset", 1);
- // Current include file
- Names[C_Include] = new tConfigEntry(".include", "");
+ // Current include file.
+ mNames[C_Include] = new JZConfigEntry(".include", "");
- // Entries with empty values
- Names[C_BankTable] = new tConfigEntry(".bank_table");
- Names[C_VoiceNames] = new tConfigEntry(".voicenames");
- Names[C_DrumSets] = new tConfigEntry(".drumsets");
- Names[C_CtrlNames] = new tConfigEntry(".ctrlnames");
- Names[C_DrumNames] = new tConfigEntry(".drumnames");
+ // Entries with empty values.
+ mNames[C_BankTable] = new JZConfigEntry(".bank_table");
+ mNames[C_VoiceNames] = new JZConfigEntry(".voicenames");
+ mNames[C_DrumSets] = new JZConfigEntry(".drumsets");
+ mNames[C_CtrlNames] = new JZConfigEntry(".ctrlnames");
+ mNames[C_DrumNames] = new JZConfigEntry(".drumnames");
- // The startup song
- Names[C_StartUpSong] = new tConfigEntry(".startup_song", "jazz.mid");
- Names[C_OssBug1] = new tConfigEntry(".ossbug1", 0);
- Names[C_OssBug2] = new tConfigEntry(".ossbug2", 0);
- Names[C_DuplexAudio] = new tConfigEntry(".duplex_audio", 0);
- Names[C_ThruInput] = new tConfigEntry(".thru_input", 0);
- Names[C_ThruOutput] = new tConfigEntry(".thru_output", 0);
+ // The startup song.
+ mNames[C_StartUpSong] = new JZConfigEntry(".startup_song", "jazz.mid");
+ mNames[C_OssBug1] = new JZConfigEntry(".ossbug1", 0);
+ mNames[C_OssBug2] = new JZConfigEntry(".ossbug2", 0);
+ mNames[C_DuplexAudio] = new JZConfigEntry(".duplex_audio", 0);
+ mNames[C_ThruInput] = new JZConfigEntry(".thru_input", 0);
+ mNames[C_ThruOutput] = new JZConfigEntry(".thru_output", 0);
+
// Enable/disable splash dialog.
- Names[C_EnableWelcome] = new tConfigEntry(".enable_welcome", 1);
+ mNames[C_EnableWelcome] = new JZConfigEntry(".enable_welcome", 1);
- // Other initialization
+ // Other initialization.
for (int i = 0; i < 130; ++i)
{
@@ -280,48 +318,62 @@
mVoiceNames.push_back(make_pair("", 0));
}
-tConfig::~tConfig()
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZConfiguration::~JZConfiguration()
{
for (int i = 0; i < NumConfigNames; ++i)
{
- if (Names[i])
+ if (mNames[i])
{
- delete Names[i];
+ delete mNames[i];
}
}
}
-pair<string, int>& tConfig::DrumName(unsigned entry)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+const pair<string, int>& JZConfiguration::GetDrumName(unsigned entry) const
{
assert((entry >= 0) && (entry < mDrumNames.size()));
return mDrumNames[entry];
}
-pair<string, int>& tConfig::DrumSet(unsigned entry)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+const pair<string, int>& JZConfiguration::GetDrumSet(unsigned entry) const
{
assert((entry >= 0) && (entry < mDrumSets.size()));
return mDrumSets[entry];
}
-pair<string, int>& tConfig::VoiceName(unsigned entry)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+const pair<string, int>& JZConfiguration::GetVoiceName(unsigned entry) const
{
assert((entry >= 0) && (entry < mVoiceNames.size()));
return mVoiceNames[entry];
}
-pair<string, int>& tConfig::CtrlName(unsigned entry)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+const pair<string, int>& JZConfiguration::GetCtrlName(unsigned entry) const
{
assert((entry >= 0) && (entry < mCtrlNames.size()));
return mCtrlNames[entry];
}
-tDoubleCommand& tConfig::BankEntry(unsigned entry)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZDoubleCommand& JZConfiguration::BankEntry(unsigned entry)
{
assert((entry >= 0) && (entry < mBankTable.size()));
return mBankTable[entry];
}
-int tConfig::Check(const char* pName) const
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZConfiguration::Check(const char* pName) const
{
if (!pName || (pName[0] != '.'))
{
@@ -330,11 +382,11 @@
for (int i = 0; i < NumConfigNames; i++)
{
- if (!Names[i])
+ if (!mNames[i])
{
continue;
}
- if (!strncmp(pName, Names[i]->GetName(), strlen(Names[i]->GetName())))
+ if (!strncmp(pName, mNames[i]->GetName(), strlen(mNames[i]->GetName())))
{
// Found
return i;
@@ -349,7 +401,7 @@
// value has not been set by an earlier call to LoadConfig, attempt to find
// the file using FindFile().
//-----------------------------------------------------------------------------
-wxString tConfig::GetFileName()
+wxString JZConfiguration::GetFileName()
{
if (!mFileName.empty())
{
@@ -366,7 +418,9 @@
return mFileName;
}
-int tConfig::Load(char* buf)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+int JZConfiguration::Load(char* buf)
{
int entry = Check(buf);
@@ -375,17 +429,17 @@
char format[100];
int result = 1;
- if (Names[entry]->GetType() == ConfigEntryTypeInt)
+ if (mNames[entry]->GetType() == ConfigEntryTypeInt)
{
- sprintf(format, "%s %%d", Names[entry]->GetName());
+ sprintf(format, "%s %%d", mNames[entry]->GetName());
int Value;
result = sscanf(buf, format, &Value);
- Names[entry]->SetValue(Value);
+ mNames[entry]->SetValue(Value);
}
- else if (Names[entry]->GetType() == ConfigEntryTypeStr)
+ else if (mNames[entry]->GetType() == ConfigEntryTypeStr)
{
// allow whitespace inside entries like "C:\Program Files\JazzWare"
- int ofs = strlen(Names[entry]->GetName());
+ int ofs = strlen(mNames[entry]->GetName());
while (buf[ofs] == ' ' || buf[ofs] == '\t') // not \n
ofs++;
int end = strlen(buf) - 1;
@@ -399,7 +453,7 @@
char* pStringValue = new char[size + 1];
memcpy(pStringValue, buf + ofs, size);
pStringValue[size] = 0;
- Names[entry]->SetStrValue(pStringValue);
+ mNames[entry]->SetStrValue(pStringValue);
delete [] pStringValue;
}
else
@@ -417,55 +471,67 @@
}
}
-const int& tConfig::GetValue(const char* pName) const
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+const int& JZConfiguration::GetValue(const char* pName) const
{
int i = Check(pName);
assert(i >= 0);
- return Names[i]->GetValue();
+ return mNames[i]->GetValue();
}
-const int& tConfig::GetValue(int Index) const
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+const int& JZConfiguration::GetValue(int Index) const
{
assert((Index >= 0) && (Index < NumConfigNames));
- return Names[Index]->GetValue();
+ return mNames[Index]->GetValue();
}
-bool tConfig::Get(int entry, char *value)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+bool JZConfiguration::Get(int entry, char *value)
{
- assert((entry >= 0) && (entry < NumConfigNames));
+ assert((entry >= 0) && (entry < NumConfigNames));
- wxString FileName = GetFileName();
- if (FileName.IsEmpty())
- {
- return false;
- }
+ wxString FileName = GetFileName();
+ if (FileName.IsEmpty())
+ {
+ return false;
+ }
- FILE *fd = fopen(FileName.c_str(), "r");
- const char* name = Name(entry);
+ FILE *fd = fopen(FileName.c_str(), "r");
+ const char* name = GetName(entry);
- int len = strlen(name);
- char buf[1000];
- bool found = false;
- while (!found && fgets(buf, sizeof(buf), fd) != NULL)
- {
- if (strncmp(buf, name, len) == 0)
+ int len = strlen(name);
+ char buf[1000];
+ bool found = false;
+ while (!found && fgets(buf, sizeof(buf), fd) != NULL)
+ {
+ if (strncmp(buf, name, len) == 0)
+ {
+ while (isspace(buf[len]))
{
- while (isspace(buf[len]))
- len++;
- int end = strlen(buf) - 1;
- while (end > 0 && isspace(buf[end]))
- buf[end--] = 0;
- strcpy(value, buf + len);
- found = true;
+ len++;
}
- }
- fclose(fd);
- return found;
+ int end = strlen(buf) - 1;
+ while (end > 0 && isspace(buf[end]))
+ {
+ buf[end--] = 0;
+ }
+ strcpy(value, buf + len);
+ found = true;
+ }
+ }
+ fclose(fd);
+ return found;
}
-bool tConfig::Get(int entry, long &value)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+bool JZConfiguration::Get(int entry, long &value)
{
char buf[512];
if (Get(entry, buf))
@@ -482,7 +548,7 @@
// entries to there. If the name/value pair is found, replace it, otherwise
// write it. Finally copy the temp file over the old configuration file.
//-----------------------------------------------------------------------------
-bool tConfig::Put(int Index, const char *value)
+bool JZConfiguration::Put(int Index, const char *value)
{
assert((Index >= 0) && (Index < NumConfigNames));
@@ -502,7 +568,7 @@
}
FILE* inp = fopen(FileName.c_str(), "r");
- const char* name = Name(Index);
+ const char* name = GetName(Index);
int len = strlen(name);
char buf[1000];
@@ -530,26 +596,32 @@
return true;
}
-bool tConfig::Put(int Index, long Value)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+bool JZConfiguration::Put(int Index, long Value)
{
ostringstream Oss;
Oss << Value;
return Put(Index, Oss.str().c_str());
}
-bool tConfig::Put(int Index)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+bool JZConfiguration::Put(int Index)
{
assert((Index >= 0) && (Index < NumConfigNames));
- Names[Index]->SetValue(Index);
- long LongValue = Names[Index]->GetValue();
+ mNames[Index]->SetValue(Index);
+ long LongValue = mNames[Index]->GetValue();
return Put(Index, LongValue);
}
-bool tConfig::Put(int Index, int Value)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+bool JZConfiguration::Put(int Index, int Value)
{
assert((Index >= 0) && (Index < NumConfigNames));
- Names[Index]->SetValue(Value);
- long LongValue = Names[Index]->GetValue();
+ mNames[Index]->SetValue(Value);
+ long LongValue = mNames[Index]->GetValue();
return Put(Index, LongValue);
}
@@ -557,7 +629,7 @@
// Description:
// Load the configuration from a file. This code supports file inclusion.
//-----------------------------------------------------------------------------
-void tConfig::LoadConfig(const wxString& FileName)
+void JZConfiguration::LoadConfig(const wxString& FileName)
{
if (!::wxFileExists(FileName))
{
@@ -590,7 +662,7 @@
}
cout
- << "tConfig::LoadConfig:" << '\n'
+ << "JZConfiguration::LoadConfig:" << '\n'
<< " \"" << mFileName << '"'
<< endl;
@@ -642,7 +714,7 @@
if (mBankTable.empty())
{
mBankTable.clear();
- tDoubleCommand DoubleCommand;
+ JZDoubleCommand DoubleCommand;
for (i = 0; i <= GetValue(C_MaxBankTableEntries); ++i)
{
DoubleCommand.Command[0] = -1;
@@ -677,7 +749,7 @@
case C_Include:
{
// include file
- wxString pathname = FindFile(StrValue(entry));
+ wxString pathname = FindFile(GetStrValue(entry));
cout << "include " << entry << endl;
IncLevel++;
assert(IncLevel < MaxIncs);
Modified: trunk/jazz/src/Configuration.h
===================================================================
--- trunk/jazz/src/Configuration.h 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Configuration.h 2008-04-11 02:25:18 UTC (rev 452)
@@ -26,13 +26,17 @@
#include <string>
#include <vector>
-class tDoubleCommand
+//*****************************************************************************
+//*****************************************************************************
+class JZDoubleCommand
{
public:
int Command[2];
};
-enum ConfigNames
+//*****************************************************************************
+//*****************************************************************************
+enum TEConfigurationNames
{
C_Seq2Device = 0,
C_MidiDriver,
@@ -103,14 +107,18 @@
NumConfigNames
};
-enum ConfigEntryType
+//*****************************************************************************
+//*****************************************************************************
+enum TEConfigEntryType
{
ConfigEntryTypeInt = 0,
ConfigEntryTypeStr,
ConfigEntryTypeEmpty
};
+//*****************************************************************************
// values for C_MidiDriver
+//*****************************************************************************
enum TEMidiDriver
{
eMidiDriverJazz = 0, // C_DRV_JAZZ 0
@@ -120,113 +128,98 @@
//*****************************************************************************
//*****************************************************************************
-class tConfigEntry
+class JZConfigEntry
{
public:
- tConfigEntry(const char* pName, int IntegerValue);
+ JZConfigEntry(const char* pName, int IntegerValue);
- tConfigEntry(const char* pName, const char* pStringValue);
+ JZConfigEntry(const char* pName, const char* pStringValue);
- tConfigEntry(const char* pName, const std::string& StringValue);
+ JZConfigEntry(const char* pName, const std::string& StringValue);
- tConfigEntry(const char* pName);
+ JZConfigEntry(const char* pName);
- ~tConfigEntry();
+ ~JZConfigEntry();
- ConfigEntryType GetType() const
+ TEConfigEntryType GetType() const
{
- return Type;
+ return mType;
}
const char* GetName() const
{
- return Name;
+ return mName;
}
const int& GetValue() const
{
- return Value;
+ return mValue;
}
void SetValue(const int& value)
{
- Value = value;
+ mValue = value;
}
const char* GetStrValue() const
{
- return StrValue;
+ return mStrValue;
}
void SetStrValue(const char* pStringValue);
private:
- ConfigEntryType Type;
- char* Name;
- int Value;
- char* StrValue;
+ TEConfigEntryType mType;
+ char* mName;
+ int mValue;
+ char* mStrValue;
};
//*****************************************************************************
//*****************************************************************************
-class tConfig
+class JZConfiguration
{
public:
- tConfig();
+ JZConfiguration();
- ~tConfig();
+ ~JZConfiguration();
void LoadConfig(const wxString& FileName);
int Check(const char* pName) const;
+
int Load(char* buf);
- std::pair<std::string, int>& DrumName(unsigned entry);
- std::pair<std::string, int>& DrumSet(unsigned entry);
- std::pair<std::string, int>& VoiceName(unsigned entry);
- std::pair<std::string, int>& CtrlName(unsigned entry);
- tDoubleCommand& BankEntry(unsigned entry);
+ const std::pair<std::string, int>& GetDrumName(unsigned entry) const;
+ const std::pair<std::string, int>& GetDrumSet(unsigned entry) const;
+ const std::pair<std::string, int>& GetVoiceName(unsigned entry) const;
+ const std::pair<std::string, int>& GetCtrlName(unsigned entry) const;
- const char* Name(int entry)
- {
- assert((entry >= 0) && (entry < NumConfigNames));
- return Names[entry]->GetName();
- }
+ JZDoubleCommand& BankEntry(unsigned entry);
- const char* StrValue(int entry)
- {
- assert((entry >= 0) && (entry < NumConfigNames));
- return Names[entry]->GetStrValue();
- }
+ const char* GetName(int entry) const;
+ const char* GetStrValue(int entry) const;
+
const int& GetValue(const char* pName) const;
const int& GetValue(int Index) const;
- bool Get(int entry, char *value);
- bool Get(int entry, long &value);
+ bool Get(int entry, char* value);
+ bool Get(int entry, long& value);
bool Put(int entry, const char *value);
bool Put(int entry, long value);
bool Put(int entry);
bool Put(int entry, int value);
- const std::vector<std::pair<std::string, int> >& GetDrumNames()
- {
- return mDrumNames;
- }
+ const std::vector<std::pair<std::string, int> >& GetDrumNames() const;
- const std::vector<std::pair<std::string, int> >& GetControlNames()
- {
- return mCtrlNames;
- }
+ const std::vector<std::pair<std::string, int> >& GetControlNames() const;
- const std::vector<std::pair<std::string, int> >& GetVoiceNames()
- {
- return mVoiceNames;
- }
+ const std::vector<std::pair<std::string, int> >& GetVoiceNames() const;
private:
@@ -240,7 +233,7 @@
wxString mFileName;
- tConfigEntry* Names[NumConfigNames];
+ JZConfigEntry* mNames[NumConfigNames];
std::vector<std::pair<std::string, int> > mDrumNames;
@@ -250,7 +243,56 @@
std::vector<std::pair<std::string, int> > mVoiceNames;
- std::vector<tDoubleCommand> mBankTable;
+ std::vector<JZDoubleCommand> mBankTable;
};
+//*****************************************************************************
+// Description:
+// These are the configuration class inline member functions.
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+inline
+const char* JZConfiguration::GetName(int entry) const
+{
+ assert((entry >= 0) && (entry < NumConfigNames));
+ return mNames[entry]->GetName();
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+inline
+const char* JZConfiguration::GetStrValue(int entry) const
+{
+ assert((entry >= 0) && (entry < NumConfigNames));
+ return mNames[entry]->GetStrValue();
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+inline
+const std::vector<std::pair<std::string, int> >&
+JZConfiguration::GetDrumNames() const
+{
+ return mDrumNames;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+inline
+const std::vector<std::pair<std::string, int> >&
+JZConfiguration::GetControlNames() const
+{
+ return mCtrlNames;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+inline
+const std::vector<std::pair<std::string, int> >&
+JZConfiguration::GetVoiceNames() const
+{
+ return mVoiceNames;
+}
+
#endif // !defined(JZ_CONFIGURATION_H)
Modified: trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp
===================================================================
--- trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -115,7 +115,7 @@
iPair != gSynthesizerTypes.end();
++iPair, ++Index)
{
- if (strcmp(iPair->first.c_str(), gpConfig->StrValue(C_SynthType)) == 0)
+ if (strcmp(iPair->first.c_str(), gpConfig->GetStrValue(C_SynthType)) == 0)
{
mOldSynthTypeName = iPair->first;
Selection = Index;
Modified: trunk/jazz/src/Dialogs.cpp
===================================================================
--- trunk/jazz/src/Dialogs.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Dialogs.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -962,8 +962,8 @@
tControlDlg::tControlDlg(tControl *e, JZPianoWindow* w, JZTrack *t)
- : tChEventDlg(e, w, t)
- //, Choice("Controller", &gpConfig->CtrlName(0), &Control)
+ : tChEventDlg(e, w, t)//,
+// Choice("Controller", &gpConfig->GetCtrlName(0), &Control)
{
Event = e;
Value = e->Value;
@@ -982,7 +982,7 @@
void tControlDlg::AddProperties()
{
// Add(Choice.mkFormItem(300, 300));
- //, Choice("Controller", &gpConfig->CtrlName(0), &Control)
+// Choice("Controller", &gpConfig->GetCtrlName(0), &Control)
sheet->AddProperty(new wxProperty(
"Controller",
tNamedValueListValue(&Control, gpConfig->GetControlNames()),
@@ -1168,8 +1168,8 @@
tProgramDlg::tProgramDlg(tProgram *e, JZPianoWindow* w, JZTrack *t)
: tEventDlg(e, w, t),
- Program(e->Program + 1)
- //, Choice("Program", &gpConfig->VoiceName(0), &Program)
+ Program(e->Program + 1)//,
+// Choice("Program", &gpConfig->GetVoiceName(0), &Program)
{
Event = e;
}
Modified: trunk/jazz/src/Globals.cpp
===================================================================
--- trunk/jazz/src/Globals.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Globals.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -31,7 +31,7 @@
using namespace std;
-tConfig* gpConfig = 0;
+JZConfiguration* gpConfig = 0;
JZSong* gpSong = 0;
Modified: trunk/jazz/src/Globals.h
===================================================================
--- trunk/jazz/src/Globals.h 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Globals.h 2008-04-11 02:25:18 UTC (rev 452)
@@ -29,7 +29,7 @@
// #define DEBUG(x) x
#define DEBUG(x)
-class tConfig;
+class JZConfiguration;
class JZSong;
class JZSynth;
class JZPlayer;
@@ -45,7 +45,7 @@
eMaxTrackCount = 127
};
-extern tConfig* gpConfig;
+extern JZConfiguration* gpConfig;
extern JZSong* gpSong;
extern JZSynth* gpSynth;
extern JZPlayer* gpMidiPlayer;
Modified: trunk/jazz/src/PianoWindow.cpp
===================================================================
--- trunk/jazz/src/PianoWindow.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/PianoWindow.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -1220,7 +1220,7 @@
while (Pitch >= 0 && y < mEventsY + mEventsHeight)
{
Dc.DrawText(
- gpConfig->DrumName(Pitch + 1).first.c_str(),
+ gpConfig->GetDrumName(Pitch + 1).first.c_str(),
mCanvasX + mLittleBit,
y);
@@ -1235,7 +1235,7 @@
while (Pitch >= 0 && y < mEventsY + mEventsHeight)
{
Dc.DrawText(
- gpConfig->CtrlName(Pitch + 1).first.c_str(),
+ gpConfig->GetCtrlName(Pitch + 1).first.c_str(),
mCanvasX + mLittleBit,
y);
@@ -1249,7 +1249,7 @@
while (Pitch >= 0 && y < mEventsY + mEventsHeight)
{
Dc.DrawText(
- gpConfig->VoiceName(Pitch + 1).first.c_str(),
+ gpConfig->GetVoiceName(Pitch + 1).first.c_str(),
mCanvasX + mLittleBit,
y);
@@ -2522,7 +2522,7 @@
mpCtrlEdit = new tCtrlEdit(
i - 1,
this,
- gpConfig->CtrlName(i).first.c_str(),
+ gpConfig->GetCtrlName(i).first.c_str(),
mPianoWidth,
0,
CtrlY(Height),
Modified: trunk/jazz/src/Project.cpp
===================================================================
--- trunk/jazz/src/Project.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Project.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -134,7 +134,7 @@
gSynthesierTypeFiles.push_back(make_pair("other.jzi", SynthTypeOther));
}
- mpConfig = new tConfig;
+ mpConfig = new JZConfiguration;
gpConfig = mpConfig;
ReadConfiguration();
@@ -143,9 +143,9 @@
mMetronomeInfo.ReadFromConfiguration();
- if (mpConfig->StrValue(C_SynthType))
+ if (mpConfig->GetStrValue(C_SynthType))
{
- mpSynth = NewSynth(mpConfig->StrValue(C_SynthType));
+ mpSynth = NewSynth(mpConfig->GetStrValue(C_SynthType));
}
else
{
@@ -316,7 +316,7 @@
}
else
{
- StartUpSong = mpConfig->StrValue(C_StartUpSong);
+ StartUpSong = mpConfig->GetStrValue(C_StartUpSong);
}
FILE* pFd = fopen(StartUpSong.c_str(), "r");
@@ -393,20 +393,6 @@
<< endl;
mpConfig->LoadConfig(ConfFileNameAndPath);
-
- DEBUG(
- if (BankTable != (tDoubleCommand *) NULL)
- {
- for (int i = 0; BankTable[i].Command[0] >= 0; i++)
- {
- cerr
- << "Bank " << i << ": "
- << BankTable[i].Command[0]
- << ' ' << BankTable[i].Command[1]
- << endl;
- }
- }
- )
}
else
{
Modified: trunk/jazz/src/Project.h
===================================================================
--- trunk/jazz/src/Project.h 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Project.h 2008-04-11 02:25:18 UTC (rev 452)
@@ -171,7 +171,7 @@
static wxString mConfFileName;
- tConfig* mpConfig;
+ JZConfiguration* mpConfig;
JZPlayer* mpMidiPlayer;
Modified: trunk/jazz/src/Rhythm.cpp
===================================================================
--- trunk/jazz/src/Rhythm.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Rhythm.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -891,8 +891,10 @@
{
r->parm = SelectControllerDlg();
if (r->parm < 0)
+ {
return;
- r->SetLabel(gpConfig->CtrlName(r->parm).first.c_str());
+ }
+ r->SetLabel(gpConfig->GetCtrlName(r->parm).first.c_str());
r->mode = MODE_CONTROL;
r->n_keys = 0;
}
Modified: trunk/jazz/src/Track.cpp
===================================================================
--- trunk/jazz/src/Track.cpp 2008-04-09 22:10:26 UTC (rev 451)
+++ trunk/jazz/src/Track.cpp 2008-04-11 02:25:18 UTC (rev 452)
@@ -1703,7 +1703,7 @@
: wxForm(USED_WXFORM_BUTTONS),
PatchChoice(
"Patch",
- t->IsDrumTrack() ? &gpConfig->DrumSet(0) : &gpConfig->VoiceName(0),
+ t->IsDrumTrack() ? &gpConfig->GetDrumSet(0) : &gpConfig->GetVoiceName(0),
&PatchNr),
DeviceChoice("Device", gpMidiPlayer->GetOutputDevices().AsNamedValue(), &Device)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|