From: <pst...@us...> - 2008-11-15 23:52:37
|
Revision: 631 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=631&view=rev Author: pstieber Date: 2008-11-15 23:52:28 +0000 (Sat, 15 Nov 2008) Log Message: ----------- Converted a couple of C-style buffers to wxStrings. Modified Paths: -------------- trunk/jazz/src/Audio.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2008-11-15 23:51:07 UTC (rev 630) +++ trunk/jazz/src/Audio.cpp 2008-11-15 23:52:28 UTC (rev 631) @@ -307,9 +307,12 @@ } if (!wxFileExists(fname)) { - char buf[500]; - sprintf(buf, "File not found: \"%s\"", fname); - wxMessageBox(buf, "Error", wxOK); + wxString String; + String + << "File not found: \"" + << fname + << '"'; + ::wxMessageBox(String, "Error", wxOK); continue; } assert(0 <= key && key < MAXSMPL); @@ -320,9 +323,12 @@ samples[key]->SetPitch(pitch); if (samples[key]->Load()) { - char buf[500]; - sprintf(buf, "could not load \"%s\"", samples[key]->GetFilename()); - wxMessageBox(buf, "Error", wxOK); + wxString String; + String + << "Could not load: \"" + << samples[key]->GetFilename() + << '"'; + ::wxMessageBox(String, "Error", wxOK); } if (samplewin[key]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2009-01-01 03:20:37
|
Revision: 672 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=672&view=rev Author: pstieber Date: 2009-01-01 03:20:32 +0000 (Thu, 01 Jan 2009) Log Message: ----------- 1. Changed to use the new versions of ReadString and WriteString. 2. Replaced some char buffers with STL strings. 3. Renamed some variables. Modified Paths: -------------- trunk/jazz/src/Audio.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2009-01-01 03:18:28 UTC (rev 671) +++ trunk/jazz/src/Audio.cpp 2009-01-01 03:20:32 UTC (rev 672) @@ -38,6 +38,7 @@ #include "Help.h" #include "Resources.h" +#include <wx/filename.h> #include <wx/listbox.h> #include <wx/msgdlg.h> #include <wx/slider.h> @@ -45,8 +46,9 @@ #include <cassert> #include <cmath> #include <cstdlib> -#include <fstream> #include <iostream> +#include <fstream> +#include <sstream> #include <sys/stat.h> #include <string.h> @@ -271,9 +273,7 @@ //----------------------------------------------------------------------------- int tSampleSet::Load(const wxString& FileName) { - int version; - - // enable audio when loading a sample set + // Enable audio when loading a sample set. gpMidiPlayer->SetAudioEnabled(true); wxBeginBusyCursor(); @@ -282,66 +282,59 @@ samples[i]->Clear(); } - // path of the spl file + // Get the path of the sample file. wxString SplFilePath = ::wxPathOnly(FileName); - ifstream is(FileName.c_str()); - is >> version >> speed >> channels >> softsync; - while (is) + ifstream Is(FileName.c_str()); + int Version; + Is >> Version >> speed >> channels >> softsync; + while (Is) { int key, pan, vol, pitch; - char fname[128]; - fname[0] = 0; - char label[500]; - is >> key; - ReadString(is, fname, sizeof(fname)); - ReadString(is, label, sizeof(label)); - is >> pan >> vol >> pitch; - if (fname[0]) + wxFileName SampleFileName; + Is >> key; + string FileNameString; + ReadString(Is, FileNameString); + SampleFileName.Assign(FileNameString); + string Label; + ReadString(Is, Label); + Is >> pan >> vol >> pitch; + if (!SampleFileName.FileExists()) { - if (!wxFileExists(fname)) - { - // try to prepend the SplFilePath - char tmp[128]; - strcpy(tmp, SplFilePath.c_str()); - strcat(tmp, "/"); - strcat(tmp, fname); - strcpy(fname, tmp); - } - if (!wxFileExists(fname)) - { - wxString String; - String - << "File not found: \"" - << fname - << '"'; - ::wxMessageBox(String, "Error", wxOK); - continue; - } - assert(0 <= key && key < MAXSMPL); - samples[key]->SetFilename(fname); - samples[key]->SetLabel(label); - samples[key]->SetVolume(vol); - samples[key]->SetPan(pan); - samples[key]->SetPitch(pitch); - if (samples[key]->Load()) - { - wxString String; - String - << "Could not load: \"" - << samples[key]->GetFilename() - << '"'; - ::wxMessageBox(String, "Error", wxOK); - } - if (samplewin[key]) - { - samplewin[key]->Redraw(); - } + // Try to prepend the sample file path. + wxString PathAndFileName; + PathAndFileName = + SplFilePath + + wxFileName::GetPathSeparator() + + SampleFileName.GetFullPath(); + SampleFileName = PathAndFileName; } - else + if (!SampleFileName.FileExists()) { - break; + wxString String; + String = "File not found: \"" + SampleFileName.GetFullPath() + '"'; + ::wxMessageBox(String, "Error", wxOK); + continue; } + assert(0 <= key && key < MAXSMPL); + samples[key]->SetFilename(SplFilePath.c_str()); + samples[key]->SetLabel(Label.c_str()); + samples[key]->SetVolume(vol); + samples[key]->SetPan(pan); + samples[key]->SetPitch(pitch); + if (samples[key]->Load()) + { + wxString String; + String + << "Could not load: \"" + << samples[key]->GetFilename() + << '"'; + ::wxMessageBox(String, "Error", wxOK); + } + if (samplewin[key]) + { + samplewin[key]->Redraw(); + } } wxEndBusyCursor(); dirty = 0; @@ -367,7 +360,7 @@ { tSample *spl = samples[i]; const char *fname = spl->GetFilename(); - const char *label = spl->GetLabel(); + const char* pLabel = spl->GetLabel(); int vol = spl->GetVolume(); int pan = spl->GetPan(); int pitch = spl->GetPitch(); @@ -376,7 +369,7 @@ os << i << " "; WriteString(os, fname); os << " "; - WriteString(os, label); + WriteString(os, pLabel); os << " " << pan << " " << vol << " " << pitch << endl; } } @@ -663,8 +656,8 @@ wxSlider *vol; wxSlider *pitch; #ifdef OBSOLETE - wxText *label; - wxText *file; + wxText* pLabel; + wxText* pFile; #endif // OBSOLETE static char *path; @@ -1089,7 +1082,7 @@ pitch = new wxSlider(this, (wxFunction)0, " ", 0, -12, 12, 200); (void) new wxMessage(this, "Pitch"); NewLine(); - label = new wxText(this, (wxFunction)0, "Label", "", -1, -1, 300); + pLabel = new wxText(this, (wxFunction)0, "Label", "", -1, -1, 300); NewLine(); file = new wxText(this, (wxFunction)0, "File", "", -1, -1, 300); NewLine(); @@ -1104,11 +1097,10 @@ //----------------------------------------------------------------------------- char *tSamplesDlg::ListEntry(int i) { - char buf[500]; - sprintf(buf, "%d ", i+1); + ostringstream Oss; + Oss << i + 1 << ' ' << set.samples[i]->GetLabel(); // KeyToString(i, buf + strlen(buf)); - sprintf(buf + strlen(buf), set.samples[i]->GetLabel()); - return copystring(buf); + return copystring(Oss.str().c_str()); } //----------------------------------------------------------------------------- @@ -1120,7 +1112,7 @@ pitch->SetValue(spl->GetPitch()); pan->SetValue(spl->GetPan()); #ifdef OBSOLETE - label->SetValue((char *)spl->GetLabel()); + pLabel->SetValue((char *)spl->GetLabel()); file->SetValue((char *)spl->GetFilename()); #endif } @@ -1134,7 +1126,7 @@ spl->SetVolume(vol->GetValue()); spl->SetPan(pan->GetValue()); #ifdef OBSOLETE - spl->SetLabel(label->GetValue()); + spl->SetLabel(pLabel->GetValue()); spl->SetFilename(file->GetValue()); #endif } @@ -1184,7 +1176,7 @@ { #ifdef OBSOLETE file->SetValue(fname); - label->SetValue(wxFileNameFromPath(fname)); + pLabel->SetValue(wxFileNameFromPath(fname)); #endif Win2Sample(current); SetCurrentListEntry(current); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2010-07-17 04:19:37
|
Revision: 796 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=796&view=rev Author: pstieber Date: 2010-07-17 04:19:30 +0000 (Sat, 17 Jul 2010) Log Message: ----------- Changed the way an open samples dialog is handles. Modified Paths: -------------- trunk/jazz/src/Audio.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2010-07-17 03:49:51 UTC (rev 795) +++ trunk/jazz/src/Audio.cpp 2010-07-17 04:19:30 UTC (rev 796) @@ -822,9 +822,9 @@ //----------------------------------------------------------------------------- void JZSampleSet::EditAudioGlobalSettings(wxWindow* pParent) { - if (mpSampleDialog) + if (mpSampleDialog->IsShown()) { - mpSampleDialog->Show(true); + mpSampleDialog->SetFocus(); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2010-07-18 22:05:50
|
Revision: 823 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=823&view=rev Author: pstieber Date: 2010-07-18 22:05:43 +0000 (Sun, 18 Jul 2010) Log Message: ----------- 1. Added end-of-file checks. 2. Fixed the code to set the sample file name. The old code was only setting the value using the path, not the complete file name. Modified Paths: -------------- trunk/jazz/src/Audio.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2010-07-18 22:04:00 UTC (rev 822) +++ trunk/jazz/src/Audio.cpp 2010-07-18 22:05:43 UTC (rev 823) @@ -292,11 +292,15 @@ ifstream Is(FileName.c_str()); int Version; Is >> Version >> mSamplingRate >> mChannelCount >> mSoftwareSynchonization; - while (Is) + while (Is && !Is.eof()) { int key, pan, vol, pitch; wxFileName SampleFileName; Is >> key; + if (Is.fail()) + { + break; + } string FileNameString; ReadString(Is, FileNameString); SampleFileName.Assign(FileNameString); @@ -321,7 +325,7 @@ continue; } assert(0 <= key && key < eSampleCount); - mSamples[key]->SetFileName(SplFilePath.c_str()); + mSamples[key]->SetFileName(SampleFileName.GetFullPath().c_str()); mSamples[key]->SetLabel(Label.c_str()); mSamples[key]->SetVolume(vol); mSamples[key]->SetPan(pan); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2011-08-05 20:33:51
|
Revision: 886 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=886&view=rev Author: pstieber Date: 2011-08-05 20:33:45 +0000 (Fri, 05 Aug 2011) Log Message: ----------- Changed c_str() to wx_str() due to Microsoft template specializations. Modified Paths: -------------- trunk/jazz/src/Audio.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2011-08-05 20:30:37 UTC (rev 885) +++ trunk/jazz/src/Audio.cpp 2011-08-05 20:33:45 UTC (rev 886) @@ -289,7 +289,7 @@ // Get the path of the sample file. wxString SplFilePath = ::wxPathOnly(FileName); - ifstream Is(FileName.c_str()); + ifstream Is(FileName.wx_str()); int Version; Is >> Version >> mSamplingRate >> mChannelCount >> mSoftwareSynchonization; while (Is && !Is.eof()) @@ -364,7 +364,7 @@ //----------------------------------------------------------------------------- int JZSampleSet::Save(const wxString& FileName) { - ofstream Ofs(FileName.c_str()); + ofstream Ofs(FileName.wx_str()); Ofs << 1 << ' ' << mSamplingRate @@ -1060,7 +1060,7 @@ wh.data_length = (end_index - start_index) * sizeof(short); wh.length = wh.data_length + sizeof(WaveHeader); - ofstream os(FileName.c_str(), ios::out | ios::binary | ios::trunc); + ofstream os(FileName.wx_str(), ios::out | ios::binary | ios::trunc); os.write((char*)&wh, sizeof(wh)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |