From: <pst...@us...> - 2010-07-11 21:45:32
|
Revision: 789 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=789&view=rev Author: pstieber Date: 2010-07-11 21:45:22 +0000 (Sun, 11 Jul 2010) Log Message: ----------- 1. Changed GetFilename and SetFilename to GetFileName and SetFileName in tSample. 2. Changed the char* filename data member of tSample to std::string mFileName. 3. Changed the file name argument in tSampleSet::AddNote to std::string. 4. Changed TRUE to true and FALSE to false in SampleWindow.cpp. 5. Changed fname to FileName. Modified Paths: -------------- trunk/jazz/src/Audio.cpp trunk/jazz/src/Audio.h trunk/jazz/src/Sample.cpp trunk/jazz/src/Sample.h trunk/jazz/src/SampleWindow.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2010-07-11 21:19:45 UTC (rev 788) +++ trunk/jazz/src/Audio.cpp 2010-07-11 21:45:22 UTC (rev 789) @@ -321,7 +321,7 @@ continue; } assert(0 <= key && key < eSampleCount); - mSamples[key]->SetFilename(SplFilePath.c_str()); + mSamples[key]->SetFileName(SplFilePath.c_str()); mSamples[key]->SetLabel(Label.c_str()); mSamples[key]->SetVolume(vol); mSamples[key]->SetPan(pan); @@ -331,7 +331,7 @@ wxString String; String << "Could not load: \"" - << mSamples[key]->GetFilename() + << mSamples[key]->GetFileName() << '"'; ::wxMessageBox(String, "Error", wxOK); } @@ -365,14 +365,14 @@ for (int i = 0; i < eSampleCount; i++) { tSample* pSample = mSamples[i]; - const char* fname = pSample->GetFilename(); + const string& FileName = pSample->GetFileName(); int vol = pSample->GetVolume(); int pan = pSample->GetPan(); int pitch = pSample->GetPitch(); - if (fname[0]) + if (!FileName.empty()) { Ofs << i << ' '; - WriteString(Ofs, fname); + WriteString(Ofs, FileName); Ofs << ' '; WriteString(Ofs, pSample->GetLabel()); Ofs << ' ' << pan << ' ' << vol << ' ' << pitch << endl; @@ -850,15 +850,15 @@ //----------------------------------------------------------------------------- void tSampleSet::LoadSampleSet(wxWindow* pParent) { - wxString fname = file_selector( + wxString FileName = file_selector( mDefaultFileName, "Load Sample Set", false, has_changed, "*.spl"); - if (fname) + if (FileName) { - Load(fname); + Load(FileName); } } @@ -867,15 +867,15 @@ //----------------------------------------------------------------------------- void tSampleSet::SaveSampleSetAs(wxWindow* pParent) { - wxString fname = file_selector( + wxString FileName = file_selector( mDefaultFileName, "Save Sample Set", true, has_changed, "*.spl"); - if (fname) + if (FileName) { - Save(fname); + Save(FileName); } } @@ -948,17 +948,19 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tSampleSet::AddNote(const char *fname, long frc, long toc) +void tSampleSet::AddNote(const string& FileName, long frc, long toc) { int i; tSample *spl; - // see if fname is already present in sample list + // See if the file name is already present in sample list. for (i = 0; i < eSampleCount; i++) { spl = mSamples[i]; - if (strcmp(spl->GetFilename(), fname) == 0) + if (spl->GetFileName() == FileName) + { break; + } } // if no entry is there, add an entry @@ -968,8 +970,10 @@ for (i = 15; i < eSampleCount; i++) { spl = mSamples[i]; - if (spl->GetFilename()[0] == 0) + if (spl->GetFileName()[0] == 0) + { break; + } } } @@ -978,8 +982,8 @@ int key = i; spl->Clear(); // reset everything to defaults - spl->SetFilename(fname); - spl->SetLabel(wxFileNameFromPath((char *)fname)); + spl->SetFileName(FileName); + spl->SetLabel(wxFileNameFromPath(FileName)); spl->Load(); // reload data // delete selection @@ -1203,7 +1207,7 @@ mpPanSlider->SetValue(spl->GetPan()); #ifdef OBSOLETE pLabel->SetValue((char *)spl->GetLabel()); - file->SetValue((char *)spl->GetFilename()); + file->SetValue((char *)spl->GetFileName()); #endif } @@ -1217,7 +1221,7 @@ spl->SetPan(mpPanSlider->GetValue()); #ifdef OBSOLETE spl->SetLabel(pLabel->GetValue()); - spl->SetFilename(file->GetValue()); + spl->SetFileName(file->GetValue()); #endif } Modified: trunk/jazz/src/Audio.h =================================================================== --- trunk/jazz/src/Audio.h 2010-07-11 21:19:45 UTC (rev 788) +++ trunk/jazz/src/Audio.h 2010-07-11 21:45:22 UTC (rev 789) @@ -363,7 +363,7 @@ long toc, tAudioRecordBuffer &buf); - void AddNote(const char *fname, long frc, long toc); + void AddNote(const std::string& FileName, long frc, long toc); void RefreshDialogs(); Modified: trunk/jazz/src/Sample.cpp =================================================================== --- trunk/jazz/src/Sample.cpp 2010-07-11 21:19:45 UTC (rev 788) +++ trunk/jazz/src/Sample.cpp 2010-07-11 21:45:22 UTC (rev 789) @@ -40,13 +40,13 @@ tSample::tSample(tSampleSet &s) : set(s), - mLabel() + mLabel(), + mFileName() { data = 0; length = 0; external_flag = 1; // auto reload when file changes on disk external_time = 0; - filename = copystring(""); volume = 127; pan = 0; pitch = 0; @@ -57,7 +57,6 @@ tSample::~tSample() { delete [] data; - delete [] filename; } void tSample::SetLabel(const std::string& Label) @@ -65,25 +64,21 @@ mLabel = Label; } -void tSample::SetFilename(const char *fname) +void tSample::SetFileName(const string& FileName) { - if (strcmp(filename, fname) != 0) + if (mFileName != FileName) { dirty = 1; - char *s = copystring(fname); - mLabel = wxFileNameFromPath(s); - delete [] s; + mLabel = wxFileNameFromPath(FileName.c_str()); } - delete [] filename; - filename = copystring(fname); + mFileName = FileName; } void tSample::Clear() { FreeData(); mLabel.clear(); - delete [] filename; - filename = copystring(""); + mFileName.clear(); volume = 127; pan = 0; pitch = 0; @@ -171,15 +166,15 @@ int tSample::LoadWav() { struct stat buf; - if (stat(filename, &buf) == -1) + if (stat(mFileName.c_str(), &buf) == -1) { - perror(filename); + perror(mFileName.c_str()); return 1; } external_time = buf.st_mtime; // read and check header info - ifstream is(filename, ios::binary | ios::in); + ifstream is(mFileName.c_str(), ios::binary | ios::in); WaveHeader wh; memset(&wh, 0, sizeof(wh)); is.read((char *)&wh, sizeof(wh)); @@ -188,12 +183,12 @@ || wh.sub_chunk != FMT || wh.data_chunk != DATA) { - //fprintf(stderr, "%s format not recognized\n", filename); + //fprintf(stderr, "%s format not recognized\n", mFileName.c_str()); return 2; } if (wh.format != PCM_CODE) { - //fprintf(stderr, "%s must be PCM_CODE\n", filename); + //fprintf(stderr, "%s must be PCM_CODE\n", mFileName.c_str()); return 3; } @@ -230,9 +225,9 @@ int tSample::LoadWav() { struct stat buf; - if (stat(filename, &buf) == -1) + if (stat(mFileName.c_str(), &buf) == -1) { - perror(filename); + perror(mFileName.c_str()); return 1; } external_time = buf.st_mtime; @@ -240,7 +235,7 @@ ChunkHeader ch; // read and check header info - ifstream is(filename, ios::binary | ios::in); + ifstream is(mFileName.c_str(), ios::binary | ios::in); RIFFHeader rh; is.read((char *)&rh, sizeof(rh)); if (strncmp(rh.main_type, "RIFF", 4) || strncmp(rh.sub_type, "WAVE", 4)) @@ -381,15 +376,15 @@ { // determine file size struct stat buf; - if (stat(filename, &buf) == -1) + if (stat(mFileName.c_str(), &buf) == -1) { - perror(filename); + perror(mFileName.c_str()); return 1; } length = buf.st_size/2; external_time = buf.st_mtime; - ifstream is(filename, ios::binary | ios::in); + ifstream is(mFileName.c_str(), ios::binary | ios::in); data = new short [length]; is.read((char *)data, length * 2); return 0; @@ -399,12 +394,12 @@ int tSample::Load(int force) { // sample modified on disk? - if (filename && filename[0] && !force && !dirty && external_flag) + if (!mFileName.empty() && !force && !dirty && external_flag) { struct stat buf; - if (stat(filename, &buf) == -1) + if (stat(mFileName.c_str(), &buf) == -1) { - perror(filename); + perror(mFileName.c_str()); return 1; } if (external_time != buf.st_mtime) @@ -414,7 +409,7 @@ if (force || dirty) { FreeData(); - if (filename && filename[0]) + if (!mFileName.empty()) { int rc = LoadWav(); dirty = 0; @@ -703,9 +698,9 @@ wh.length = wh.data_length + sizeof(WaveHeader); #ifdef __WXMSW__ - unlink(filename); // buggy, sigh! + unlink(mFileName.c_str()); // buggy, sigh! #endif - ofstream os(filename, ios::out | ios::binary | ios::trunc); + ofstream os(mFileName.c_str(), ios::out | ios::binary | ios::trunc); os.write((char *)&wh, sizeof(wh)); os.write((char *)data, length * sizeof(short)); Modified: trunk/jazz/src/Sample.h =================================================================== --- trunk/jazz/src/Sample.h 2010-07-11 21:19:45 UTC (rev 788) +++ trunk/jazz/src/Sample.h 2010-07-11 21:45:22 UTC (rev 789) @@ -258,10 +258,10 @@ return pitch; } - void SetFilename(const char *fname); - const char *GetFilename() const + void SetFileName(const std::string& FileName); + const std::string& GetFileName() const { - return filename; + return mFileName; } int GetLength() const @@ -412,7 +412,7 @@ tSampleSet& set; std::string mLabel; - char* filename; + std::string mFileName; int volume; int pan; int pitch; // delta pitch Modified: trunk/jazz/src/SampleWindow.cpp =================================================================== --- trunk/jazz/src/SampleWindow.cpp 2010-07-11 21:19:45 UTC (rev 788) +++ trunk/jazz/src/SampleWindow.cpp 2010-07-11 21:45:22 UTC (rev 789) @@ -219,7 +219,7 @@ player(p), spl(s) { - visible = FALSE; + visible = false; x = 0; } @@ -301,7 +301,7 @@ sel_fr = sel_to = -1; mouse_up_sets_insertion_point = 0; playpos = new tSamplePlayPosition(*this, gpMidiPlayer, spl); - midi_time = TRUE; + midi_time = true; midi_offs = 0; mouse_down = 0; } @@ -340,7 +340,7 @@ if (MouseEvent.LeftDown()) { mouse_up_sets_insertion_point = 0; - mouse_down = TRUE; + mouse_down = true; if (snapsel.IsSelected()) { snapsel.Draw(*pDc, 0, 0); @@ -358,7 +358,7 @@ } else if (MouseEvent.LeftUp()) { - mouse_down = FALSE; + mouse_down = false; snapsel.ProcessMouseEvent(MouseEvent, 0, 0); if (snapsel.IsSelected()) { @@ -668,16 +668,16 @@ static JZToolDef tdefs[] = { - { wxID_OPEN, FALSE, open_xpm, "open wave file" }, - { wxID_SAVE, FALSE, save_xpm, "save wave file" }, + { wxID_OPEN, false, open_xpm, "open wave file" }, + { wxID_SAVE, false, save_xpm, "save wave file" }, { JZToolBar::eToolBarSeparator }, - { wxID_ZOOM_IN, FALSE, zoomin_xpm, "zoom to selection" }, - { wxID_ZOOM_OUT, FALSE, zoomout_xpm, "zoom out" }, - { MEN_ACCEPT, FALSE, accept_xpm, "accept painting" }, - { ID_PAINTER_NONE, FALSE, cancel_xpm, "cancel painting" }, + { wxID_ZOOM_IN, false, zoomin_xpm, "zoom to selection" }, + { wxID_ZOOM_OUT, false, zoomout_xpm, "zoom out" }, + { MEN_ACCEPT, false, accept_xpm, "accept painting" }, + { ID_PAINTER_NONE, false, cancel_xpm, "cancel painting" }, { JZToolBar::eToolBarSeparator }, - { ID_PLAY, FALSE, play_xpm, "play sample" }, - { MEN_HELP, FALSE, help_xpm, "help" }, + { ID_PLAY, false, play_xpm, "play sample" }, + { MEN_HELP, false, help_xpm, "help" }, { JZToolBar::eToolBarEnd } }; @@ -692,11 +692,11 @@ tSample *tSampleWin::copy_buffer; -tSampleWin::tSampleWin(wxWindow* pParent, tSampleWin **ref, tSample &sample) +tSampleWin::tSampleWin(wxWindow* pParent, tSampleWin **ref, tSample& sample) : wxFrame( pParent, wxID_ANY, - (char *)sample.GetFilename(), + sample.GetFileName(), wxPoint(geo[0], geo[1]), wxSize(geo[2], geo[3])), spl(sample), @@ -707,7 +707,7 @@ { this->ref = ref; - in_constructor = TRUE; + in_constructor = true; cnvs = 0; mpToolBar = 0; @@ -820,7 +820,7 @@ // zoom_scrol->SetValue(0); zoom_scrol->SetScrollbar(0, 10, 1000, 100); - in_constructor = FALSE; + in_constructor = false; // now force a resize for motif int cw, ch; @@ -858,7 +858,7 @@ bool tSampleWin::OnClose() { - return TRUE; + return true; } @@ -911,14 +911,14 @@ if (cnvs->sel_fr == cnvs->sel_to && cnvs->sel_fr >= 0) { offs = cnvs->sel_fr; - return TRUE; + return true; } else { offs = -1; if (warn) wxMessageBox("please set insertion point first", "Error", wxOK); - return FALSE; + return false; } } @@ -928,18 +928,18 @@ { fr_smpl = cnvs->sel_fr; to_smpl = cnvs->sel_to; - return TRUE; + return true; } else if (mode == SelAll) { fr_smpl = 0; to_smpl = spl.GetLength(); - return TRUE; + return true; } fr_smpl = to_smpl = -1; if (mode == SelWarn) wxMessageBox("please select samples first", "Error", wxOK); - return FALSE; + return false; } @@ -979,7 +979,7 @@ void tSampleWin::LoadError(tSample &spl) { char buf[500]; - sprintf(buf, "could not load \"%s\"", spl.GetFilename()); + sprintf(buf, "could not load \"%s\"", spl.GetFileName()); wxMessageBox(buf, "Error", wxOK); } @@ -1003,7 +1003,7 @@ case ID_EFFECTS_EQUALIZER: if (equalizer == 0) equalizer = new tEqualizer(*this); - equalizer->Show(TRUE); + equalizer->Show(true); break; case MEN_FLIP_LEFT: @@ -1016,7 +1016,7 @@ case ID_EFFECTS_DISTORTION: if (distortion == 0) distortion = new tDistortion(*this); - distortion->Show(TRUE); + distortion->Show(true); break; case ID_EFFECTS_REVERB: @@ -1031,7 +1031,7 @@ } ClearSelection(); SetViewPos(0, spl.GetLength()); - reverb->Show(TRUE); + reverb->Show(true); #endif break; @@ -1050,14 +1050,14 @@ #ifdef OBSOLETE if (shifter == 0) { - shifter = new wxDialogBox(this, "Shifter", FALSE ); + shifter = new wxDialogBox(this, "Shifter", false ); tShifterForm *form = new tShifterForm(*this); form->EditForm(shifter); shifter->Fit(); } ClearSelection(); SetViewPos(0, spl.GetLength()); - shifter->Show(TRUE); + shifter->Show(true); #endif break; @@ -1065,14 +1065,14 @@ #ifdef OBSOLETE if (stretcher == 0) { - stretcher = new wxDialogBox(this, "Stretcher", FALSE ); + stretcher = new wxDialogBox(this, "Stretcher", false ); tStretcherForm *form = new tStretcherForm(*this); form->EditForm(stretcher); stretcher->Fit(); } ClearSelection(); SetViewPos(0, spl.GetLength()); - stretcher->Show(TRUE); + stretcher->Show(true); #endif break; @@ -1080,12 +1080,12 @@ #ifdef OBSOLETE if (filter == 0) { - filter = new wxDialogBox(this, "Filter", FALSE ); + filter = new wxDialogBox(this, "Filter", false ); tSplFilterForm *form = new tSplFilterForm(*this); form->EditForm(filter); filter->Fit(); } - filter->Show(TRUE); + filter->Show(true); #endif break; @@ -1093,12 +1093,12 @@ #ifdef OBSOLETE if (settings == 0) { - settings = new wxDialogBox(this, "Settings", FALSE ); + settings = new wxDialogBox(this, "Settings", false ); tSmplWinSettingsForm *form = new tSmplWinSettingsForm(*this); form->EditForm(settings); settings->Fit(); } - settings->Show(TRUE); + settings->Show(true); #endif break; @@ -1106,14 +1106,14 @@ #ifdef OBSOLETE if (echo == 0) { - echo = new wxDialogBox(this, "Echo", FALSE ); + echo = new wxDialogBox(this, "Echo", false ); tEchoForm *form = new tEchoForm(*this); form->EditForm(echo); echo->Fit(); } ClearSelection(); SetViewPos(0, spl.GetLength()); - echo->Show(TRUE); + echo->Show(true); #endif break; @@ -1121,21 +1121,21 @@ #ifdef OBSOLETE if (chorus == 0) { - chorus = new wxDialogBox(this, "Chorus", FALSE ); + chorus = new wxDialogBox(this, "Chorus", false ); tChorusForm *form = new tChorusForm(*this); form->EditForm(chorus); chorus->Fit(); } ClearSelection(); SetViewPos(0, spl.GetLength()); - chorus->Show(TRUE); + chorus->Show(true); #endif break; case ID_EFFECTS_SYNTH: if (synth == 0) synth = new tSynthDlg(*this); - synth->Show(TRUE); + synth->Show(true); break; case MEN_ACCEPT: @@ -1209,12 +1209,12 @@ #ifdef OBSOLETE if (wah_settings == 0) { - wah_settings = new wxDialogBox(this, "Filter Painter", FALSE); + wah_settings = new wxDialogBox(this, "Filter Painter", false); tWahSettingsForm *form = new tWahSettingsForm(*this); form->EditForm(wah_settings); wah_settings->Fit(); } - wah_settings->Show(TRUE); + wah_settings->Show(true); #endif break; @@ -1227,7 +1227,7 @@ form->EditForm(pitch_settings); pitch_settings->Fit(); } - pitch_settings->Show(TRUE); + pitch_settings->Show(true); #endif break; @@ -1252,7 +1252,7 @@ case wxID_PASTE: { int offs, fr, to; - if (HaveInsertionPoint(offs, FALSE)) + if (HaveInsertionPoint(offs, false)) { spl.PasteIns(*copy_buffer, offs); cnvs->SetSelection(offs, offs + copy_buffer->GetLength()); @@ -1308,7 +1308,7 @@ case ID_FILE_REVERT_TO_SAVED: cnvs->ClearSelection(); - if (spl.Load(TRUE)) + if (spl.Load(true)) LoadError(spl); Redraw(); break; @@ -1324,54 +1324,50 @@ case wxID_OPEN: { - char *defname = copystring(spl.GetFilename()); - wxString fname = file_selector( - defname, + wxString FileName = file_selector( + spl.GetFileName(), "Load Sample", - FALSE, - FALSE, + false, + false, "*.wav"); - if (!fname.empty()) + if (!FileName.empty()) { wxBeginBusyCursor(); cnvs->ClearSelection(); - spl.SetFilename(fname); - if (spl.Load(TRUE)) + spl.SetFileName(FileName); + if (spl.Load(true)) { LoadError(spl); } spl->RefreshDialogs(); - SetTitle(fname); + SetTitle(FileName); Redraw(); wxEndBusyCursor(); } - delete [] defname; } break; case wxID_SAVEAS: { - char *defname = copystring(spl.GetFilename()); - wxString fname = file_selector( - defname, + wxString FileName = file_selector( + spl.GetFileName(), "Save Sample", - TRUE, - FALSE, + true, + false, "*.wav"); - if (!fname.empty()) + if (!FileName.empty()) { - spl.SetFilename(fname); + spl.SetFileName(FileName); OnMenuCommand(wxID_SAVE); spl->RefreshDialogs(); - SetTitle(fname); + SetTitle(FileName); } - delete [] defname; } break; case wxID_SAVE: { - if (spl.GetFilename()[0] == 0) + if (spl.GetFileName().empty()) { OnMenuCommand(wxID_SAVEAS); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |