From: <car...@us...> - 2006-10-27 17:10:09
|
Revision: 1119 http://svn.sourceforge.net/wired/?rev=1119&view=rev Author: carres_l Date: 2006-10-27 10:09:33 -0700 (Fri, 27 Oct 2006) Log Message: ----------- A lot of things moved Begin to remove WiredSession and WiredSessionXml SaveCenter instanciated Some debug on the save features Everything does not work yet, problem seems to come from the keys of the hashmaps. Will go back on it real soon... Modified Paths: -------------- branches/saveXml/src/dssi/Makefile.am branches/saveXml/src/dssi/WiredExternalPluginLADSPA.h branches/saveXml/src/engine/Makefile.am branches/saveXml/src/engine/WiredSession.cpp branches/saveXml/src/gui/AudioPattern.cpp branches/saveXml/src/gui/MainWindow.cpp branches/saveXml/src/gui/Makefile.am branches/saveXml/src/gui/MediaLibrary.cpp branches/saveXml/src/gui/Transport.cpp branches/saveXml/src/gui/Transport.h branches/saveXml/src/redist/Plugin.h branches/saveXml/src/save/Makefile.am branches/saveXml/src/save/SaveCenter.cpp branches/saveXml/src/save/SaveCenter.h branches/saveXml/src/save/WiredDocument.cpp branches/saveXml/src/save/WiredDocument.h branches/saveXml/src/sequencer/Makefile.am branches/saveXml/src/xml/Makefile.am branches/saveXml/src/xml/WiredSessionXml.h branches/saveXml/src/xml/WiredXml.cpp Modified: branches/saveXml/src/dssi/Makefile.am =================================================================== --- branches/saveXml/src/dssi/Makefile.am 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/dssi/Makefile.am 2006-10-27 17:09:33 UTC (rev 1119) @@ -1,4 +1,8 @@ -CPPFLAGS = $(shell wx-config --cflags) -I../gui -I../plugins -I../fileloader -I/opt/gnome/include -I../sequencer -I../redist -I../audio -I../mixer -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime -I../editmidi -I../undo -I../libs/WiredWidgets/src -I../../libs/WiredWidgets/src -Wall -Wunused +CPPFLAGS = $(shell wx-config --cflags) -I../gui -I../plugins -I../fileloader \ + -I/opt/gnome/include -I../sequencer -I../redist -I../audio -I../mixer \ + -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime \ + -I../editmidi -I../undo -I../libs/WiredWidgets/src \ + -I../../libs/WiredWidgets/src -Wall -Wunused if PORTAUDIO CPPFLAGS += -I../portaudio/include @@ -19,4 +23,5 @@ dssi.h \ WiredExternalPluginGui.cpp \ WiredExternalPluginGui.h \ - ladspa.h + ladspa.h \ + ../redist/Plugin.cpp Modified: branches/saveXml/src/dssi/WiredExternalPluginLADSPA.h =================================================================== --- branches/saveXml/src/dssi/WiredExternalPluginLADSPA.h 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/dssi/WiredExternalPluginLADSPA.h 2006-10-27 17:09:33 UTC (rev 1119) @@ -6,7 +6,7 @@ #include "ladspa.h" #include "../engine/AudioEngine.h" -#include "../redist/Plugin.h" +#include "Plugin.h" //#include <stdlib.h> #include <dlfcn.h> #include <math.h> Modified: branches/saveXml/src/engine/Makefile.am =================================================================== --- branches/saveXml/src/engine/Makefile.am 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/engine/Makefile.am 2006-10-27 17:09:33 UTC (rev 1119) @@ -21,6 +21,4 @@ RingBuffer.hxx \ RingError.h \ Settings.cpp \ - Settings.h \ - WiredSession.cpp \ - WiredSession.h + Settings.h \ No newline at end of file Modified: branches/saveXml/src/engine/WiredSession.cpp =================================================================== --- branches/saveXml/src/engine/WiredSession.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/engine/WiredSession.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -6,7 +6,7 @@ #include "WiredSession.h" #include "Sequencer.h" #include "SequencerGui.h" -#include "Transport.h" +//#include "Transport.h" #include "Rack.h" #include "AudioCenter.h" #include "../plugins/PluginLoader.h" Modified: branches/saveXml/src/gui/AudioPattern.cpp =================================================================== --- branches/saveXml/src/gui/AudioPattern.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/gui/AudioPattern.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -9,7 +9,6 @@ #include "OptionPanel.h" #include "Mixer.h" #include "AudioCenter.h" -#include "../xml/WiredSessionXml.h" #include "ColoredBox.h" #include "AudioPattern.h" #include "HelpPanel.h" @@ -18,9 +17,10 @@ #include "../engine/AudioEngine.h" #include "../audio/WriteWaveFile.h" #include "../mixer/Channel.h" +#include "SaveCenter.h" static long audio_pattern_count = 1; -extern WiredSessionXml *CurrentXmlSession; +extern SaveCenter *saveCenter; AudioPattern::AudioPattern(double pos, double endpos, long trackindex) : Pattern(pos, endpos, trackindex), @@ -202,10 +202,10 @@ int i = 1; cout << "Preparing record for pattern " << this - << " with audio dir : " << CurrentXmlSession->GetAudioDir().mb_str() << endl; + << " with audio dir : " << saveCenter->getAudioDir().mb_str() << endl; while (!done) { - s = CurrentXmlSession->GetAudioDir() + wxT("/wired_audio"); + s = saveCenter->getAudioDir() + wxT("/wired_audio"); s += wxString::Format(wxT("%d"), i); s += wxT(".wav"); Modified: branches/saveXml/src/gui/MainWindow.cpp =================================================================== --- branches/saveXml/src/gui/MainWindow.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/gui/MainWindow.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -45,6 +45,8 @@ #include "Threads.h" #include "MediaLibrary.h" #include "MLTree.h" +#include "SaveCenter.h" +//Isn't it bullshit to declare things here ? Rack *RackPanel = NULL; SequencerGui *SeqPanel = NULL; @@ -63,6 +65,8 @@ FileConversion *FileConverter = NULL; SettingWindow *SettingsWin = NULL; +SaveCenter *saveCenter = NULL; + wxMutex AudioMutex; wxCondition *SeqStopped = NULL; @@ -77,8 +81,11 @@ CreateStatusBar(2); #endif WiredSettings = new Settings(); - CurrentSession = new WiredSession(wxString(wxT(""), *wxConvCurrent)); - CurrentXmlSession = new WiredSessionXml(wxString(wxT(""), *wxConvCurrent)); + saveCenter = new SaveCenter(wxString(wxT("wired_save")), + wxString(wxT("Session_1")), + wxString(wxT("/home/kiketloule/wired_projects")), + NULL); + LoadedExternalPlugins = new WiredExternalPluginMgr(); LogWin = new wxLogWindow(this, wxT("Wired log"), false); @@ -178,7 +185,7 @@ WindowMenu->AppendSeparator(); ItemFloatingSeq = WindowMenu->AppendCheckItem(MainWin_FloatSequencer,_("Floating Sequencer")); ItemFloatingRacks = WindowMenu->AppendCheckItem(MainWin_FloatRacks, _("Floating Racks")); -// ItemFloatingOptView = WindowMenu->AppendCheckItem(MainWin_FloatView, _("Floating Optional View")); + // ItemFloatingOptView = WindowMenu->AppendCheckItem(MainWin_FloatView, _("Floating Optional View")); WindowMenu->AppendSeparator(); ItemFullscreenToggle = WindowMenu->AppendCheckItem(MainWin_FullScreen, _("&Fullscreen")); @@ -208,7 +215,7 @@ RackPanel = new Rack(split, -1, wxPoint(0, 0), wxSize(800, 250)); SeqPanel = new SequencerGui(split, wxPoint(0, 0), wxSize(800, 200), this); OptPanel = new OptionPanel(this, wxPoint(306, 452), wxSize(470, 120), wxSIMPLE_BORDER); - TransportPanel = new Transport(this, wxPoint(0, 452), wxSize(300, 150), wxNO_BORDER); + TransportPanel = new Transport(this, wxPoint(0, 452), wxSize(300, 150), wxNO_BORDER, (WiredDocument *)saveCenter); MediaLibraryPanel = new MediaLibrary(splitVert); @@ -250,7 +257,7 @@ RackModeView = true; SeqModeView = true; - // Taille minimum de la fenetre + // Minimum size of the window SetSizeHints(400, 300); Connect(MainWin_ImportWave, wxEVT_COMMAND_MENU_SELECTED, @@ -465,31 +472,34 @@ void MainWindow::InitFileConverter() { - FileConverter = new FileConversion(); - t_samplerate_info info; - int i; - if (Audio->UserData->Sets->WorkingDir.empty()) - { - wxDirDialog dir(this, _("Choose the audio working directory"), wxFileName::GetCwd(), wxDD_NEW_DIR_BUTTON | wxCAPTION | wxSUNKEN_BORDER); - if (dir.ShowModal() == wxID_OK) - CurrentXmlSession->GetAudioDir() = dir.GetPath(); - else - CurrentXmlSession->GetAudioDir() = wxFileName::GetCwd(); + //USES WIRESESSION + FileConverter = new FileConversion(); + t_samplerate_info info; + // int i; + // if (Audio->UserData->Sets->WorkingDir.empty()) + // { + // wxDirDialog dir(this, _("Choose the audio working directory"), wxFileName::GetCwd(), wxDD_NEW_DIR_BUTTON | wxCAPTION | wxSUNKEN_BORDER); + // if (dir.ShowModal() == wxID_OK) + // CurrentXmlSession->GetAudioDir() = dir.GetPath(); + // else + // CurrentXmlSession->GetAudioDir() = wxFileName::GetCwd(); - Audio->UserData->Sets->WorkingDir = CurrentXmlSession->GetAudioDir(); - } - else - { - CurrentXmlSession->GetAudioDir() = Audio->UserData->Sets->WorkingDir; + // Audio->UserData->Sets->WorkingDir = CurrentXmlSession->GetAudioDir(); + // } + // else + // { + // CurrentXmlSession->GetAudioDir() = Audio->UserData->Sets->WorkingDir; - } - info.WorkingDirectory = CurrentXmlSession->GetAudioDir(); - info.SampleRate = (unsigned long) Audio->SampleRate; - info.SamplesPerBuffer = (unsigned long) Audio->SamplesPerBuffer; - // init FileConverter with 4Mo of cache - if (FileConverter->Init(&info, CurrentXmlSession->GetAudioDir(), (unsigned long)1024 * 1024 * 4, this) == false) - cout << "[MAINWIN] Create file converter thread failed !" << endl; - MediaLibraryPanel->SetFileConverter(FileConverter); + // } + // info.WorkingDirectory = CurrentXmlSession->GetAudioDir(); + + info.WorkingDirectory = saveCenter->getAudioDir(); + info.SampleRate = (unsigned long) Audio->SampleRate; + info.SamplesPerBuffer = (unsigned long) Audio->SamplesPerBuffer; + // init FileConverter with 4Mo of cache + if (FileConverter->Init(&info, info.WorkingDirectory, (unsigned long)1024 * 1024 * 4, this) == false) + cout << "[MAINWIN] Create file converter thread failed !" << endl; + MediaLibraryPanel->SetFileConverter(FileConverter); } void MainWindow::InitUndoRedoMenuItems() @@ -603,9 +613,8 @@ delete LoadedExternalPlugins; cout << "[MAINWIN] Unloading session manager..." << endl; - delete CurrentSession; - delete CurrentXmlSession; - + delete saveCenter; + cout << "[MAINWIN] Unloading user settings manager..." << endl; if (WiredSettings) delete WiredSettings; @@ -642,8 +651,11 @@ } else if (res == wxID_CANCEL) return (false); - delete CurrentXmlSession; - CurrentXmlSession = new WiredSessionXml(wxT("")); + delete saveCenter; + saveCenter = new SaveCenter(wxString(wxT("wired_save")), + wxString(wxT("Session_1")), + wxString(wxT("/home/kiketloule/wired_project")), + NULL); Seq->Stop(); @@ -684,17 +696,18 @@ transform(selfile.begin(), selfile.end(), selfile.begin(), (int(*)(int))tolower); if (!selfile.substr(selfile.find_last_of('.')).compare(XML_EXTENSION)) { - if (CurrentXmlSession) - delete CurrentXmlSession; - CurrentXmlSession = new WiredSessionXml(selfile); - CurrentXmlSession->Load(selfile); + delete saveCenter; + saveCenter = new SaveCenter(wxString(wxT("wired_save")), + wxString(wxT("Session_1")), + wxString(wxT("/home/kiketloule/wired_project")), + NULL); + saveCenter->LoadProject(selfile); + cout << "[MAINWIN] New session loaded" << endl; } else { - cout << "[MAINWIN] Warning! Opening old format" << endl; - CurrentSession = new WiredSession(selfile); - CurrentSession->Load(); + cout << "[MAINWIN] Warning! Trying to open old format... nothing done" << endl; } } else @@ -705,86 +718,74 @@ void MainWindow::OnSave(wxCommandEvent &event) { - if (CurrentXmlSession) - { - wxString DocumentName(CurrentXmlSession->GetDocumentName()); - if (!DocumentName.empty()) - CurrentXmlSession->Save(); - else - OnSaveAs(event); - } - else - OnSaveAs(event); + saveCenter->SaveProject(); + + // if (CurrentXmlSession) + // { + // wxString DocumentName(CurrentXmlSession->GetDocumentName()); + // if (!DocumentName.empty()) + // CurrentXmlSession->Save(); + // else + // OnSaveAs(event); + // } + // else + // OnSaveAs(event); } void MainWindow::OnSaveAs(wxCommandEvent &event) { - vector<wxString> exts; + //USES WIREDSESSION +// vector<wxString> exts; - exts.insert(exts.begin(), _("xml\tWired session file (*.xml)")); - FileLoader dlg(this, MainWin_FileLoader, _("Save session"), false, true, &exts); - if (dlg.ShowModal() == wxID_OK) - { - wxString selfile = dlg.GetSelectedFile(); +// exts.insert(exts.begin(), _("xml\tWired session file (*.xml)")); +// FileLoader dlg(this, MainWin_FileLoader, _("Save session"), false, true, &exts); +// if (dlg.ShowModal() == wxID_OK) +// { +// wxString selfile = dlg.GetSelectedFile(); - wxFileName f(selfile); - if (!f.HasExt()) - selfile = selfile + XML_EXTENSION; - cout << "[MAINWIN] User saves to " << selfile.mb_str() << endl; +// wxFileName f(selfile); +// if (!f.HasExt()) +// selfile = selfile + XML_EXTENSION; +// cout << "[MAINWIN] User saves to " << selfile.mb_str() << endl; - wxString audiodir; +// wxString audiodir; - if (CurrentXmlSession) - { - audiodir = wxString(CurrentXmlSession->GetAudioDir()); - if (audiodir.size() == 0) - { - char buffer[2048]; +// if (CurrentXmlSession) +// { +// audiodir = wxString(CurrentXmlSession->GetAudioDir()); +// if (audiodir.size() == 0) +// { +// char buffer[2048]; - getcwd(buffer, 2048); - audiodir = wxString(buffer, *wxConvCurrent); - } - delete CurrentXmlSession; - } - CurrentXmlSession = new WiredSessionXml(selfile, audiodir); - CurrentXmlSession->Save(); - } +// getcwd(buffer, 2048); +// audiodir = wxString(buffer, *wxConvCurrent); +// } +// delete CurrentXmlSession; +// } +// CurrentXmlSession = new WiredSessionXml(selfile, audiodir); +// CurrentXmlSession->Save(); +// } } void MainWindow::OnImportWave(wxCommandEvent &event) { - FileLoader dlg(this, MainWin_FileLoader, _("Loading sound file"), false, false, FileConverter->GetCodecsExtensions(), true); - int res; + FileLoader dlg(this, MainWin_FileLoader, _("Loading sound file"), + false, false, FileConverter->GetCodecsExtensions(), true); + int res; if (dlg.ShowModal() == wxID_OK) { wxString selfile = dlg.GetSelectedFile(); - if (CurrentXmlSession->GetAudioDir().empty() == false) - res = wxID_OK; - else - { - wxDirDialog dir(this, _("Choose the Audio file directory"), wxFileName::GetCwd()); - if (dir.ShowModal() == wxID_OK) - { - CurrentXmlSession->GetAudioDir() = dir.GetPath(); - res = wxID_OK; - } - else - res = wxID_CANCEL; - } - if (res != wxID_CANCEL) - { - MidiMutex.Lock(); - MidiDeviceMutex.Lock(); - SeqMutex.Unlock(); - - // convert and import file - FileConverter->ImportFile(selfile); - - MidiMutex.Unlock(); - MidiDeviceMutex.Unlock(); - } + MidiMutex.Lock(); + MidiDeviceMutex.Lock(); + SeqMutex.Unlock(); + + // convert and import file + FileConverter->ImportFile(selfile); + + MidiMutex.Unlock(); + MidiDeviceMutex.Unlock(); } } @@ -813,20 +814,20 @@ if (m) { - Progress->Update(90); - for (int i = 0; i < m->GetNumberOfTracks(); i++) - { - if (m->GetTrack(i)->GetMaxPos() > 0) - { - Track *t = SeqPanel->AddTrack(false); - t->AddPattern(m->GetTrack(i)); - } - } - Progress->Update(99); - } - else - cout << "[MAINWIN] Cannot import midi file !" << endl; - delete Progress; + Progress->Update(90); + for (int i = 0; i < m->GetNumberOfTracks(); i++) + { + if (m->GetTrack(i)->GetMaxPos() > 0) + { + Track *t = SeqPanel->AddTrack(false); + t->AddPattern(m->GetTrack(i)); + } + } + Progress->Update(99); + } + else + cout << "[MAINWIN] Cannot import midi file !" << endl; + delete Progress; */ } } @@ -870,19 +871,19 @@ { Progress->Update(1); cout << "[MAINWIN] sample channel : " << sample->channels << endl; - WaveFile *w = new WaveFile(sample->buffer, sample->size, 2, sample->rate); + WaveFile *w = new WaveFile(sample->buffer, sample->size, 2, sample->rate); - if (!w->Error) - { - Track *t = SeqPanel->AddTrack(true); - Progress->Update(90); - t->AddPattern(w); - Progress->Update(99); - } - else - cout << "[MAINWIN] Cannot import AKAI wave file !" << endl; - delete Progress; - } + if (!w->Error) + { + Track *t = SeqPanel->AddTrack(true); + Progress->Update(90); + t->AddPattern(w); + Progress->Update(99); + } + else + cout << "[MAINWIN] Cannot import AKAI wave file !" << endl; + delete Progress; + } */ } } @@ -913,10 +914,10 @@ } cout << "[MAINWIN] User exports " << selfile.mb_str() << endl; if (Seq->ExportToWave(selfile) == false) - { - cout << "[MAINWIN] Export canceled by user " << endl; - return; - } + { + cout << "[MAINWIN] Export canceled by user " << endl; + return; + } wxProgressDialog Progress(_("Exporting mix"), _("Please wait..."), (int)Seq->EndLoopPos * 1000, this, @@ -1001,7 +1002,7 @@ void MainWindow::LoadExternalPlugins() { -// map<int, wstring> PluginsList; + // map<int, wstring> PluginsList; list<wxString> PluginsList; // map<int, wstring>::iterator IterPluginsList; list<wxString>::iterator IterPluginsList; @@ -1554,10 +1555,10 @@ assert(CurrentXmlSession); wxDirDialog dir(this, _("Choose the Audio file directory"), - CurrentXmlSession->GetAudioDir().empty() == true ? - wxFileName::GetCwd() : CurrentXmlSession->GetAudioDir()); + saveCenter->getAudioDir().empty() == true ? + wxFileName::GetCwd() : saveCenter->getAudioDir()); if (dir.ShowModal() == wxID_OK) - CurrentXmlSession->GetAudioDir() = dir.GetPath().c_str(); + saveCenter->setAudioDir(dir.GetPath()); } void MainWindow::OnUndo(wxCommandEvent &event) @@ -1677,8 +1678,8 @@ { wxBitmap aboutbtm; if (aboutbtm.LoadFile(wxString(WiredSettings->DataDir + - wxString(wxT("ihm/splash/about.png"))), - wxBITMAP_TYPE_PNG)) + wxString(wxT("ihm/splash/about.png"))), + wxBITMAP_TYPE_PNG)) { wxSplashScreen* splash = new wxSplashScreen(aboutbtm, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_NO_TIMEOUT, @@ -1776,14 +1777,14 @@ void MainWindow::OnShowDebug(wxCommandEvent &event) { - if(WindowMenu->IsChecked(MainWin_ShowLog)) - { - LogWin->Show(true); - } - else - { - LogWin->Show(false); - } + if(WindowMenu->IsChecked(MainWin_ShowLog)) + { + LogWin->Show(true); + } + else + { + LogWin->Show(false); + } } void MainWindow::OnKillTimer(wxTimerEvent &WXUNUSED(event)) @@ -1806,10 +1807,9 @@ LeftMemory += Size.ToString(); else LeftMemory += _("Unknown"); - if (CurrentXmlSession) - wxGetDiskSpace(CurrentXmlSession->GetAudioDir(), &Total, &Free); - else - wxGetDiskSpace(wxFileName::GetCwd(), &Total, &Free); + + wxGetDiskSpace(saveCenter->getAudioDir(), &Total, &Free); + LeftSpace += FileLoader::FormatSize((off_t) Free.GetValue()) + wxT("/") + FileLoader::FormatSize((off_t)Total.GetValue()); SetStatusText(LeftSpace, 0); SetStatusText(LeftMemory, 1); @@ -1833,14 +1833,14 @@ } BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE(wxSetCursorPos, 313131) -END_DECLARE_EVENT_TYPES() + DECLARE_EVENT_TYPE(wxSetCursorPos, 313131) + END_DECLARE_EVENT_TYPES() -BEGIN_EVENT_TABLE(MainWindow, wxFrame) -// key binding + BEGIN_EVENT_TABLE(MainWindow, wxFrame) + // key binding EVT_KEY_UP(MainWindow::OnKey) // DOWN is bugged -// menu + // menu EVT_MENU(MainWin_Quit, MainWindow::OnQuit) EVT_MENU(MainWin_New, MainWindow::OnNew) EVT_MENU(MainWin_Save, MainWindow::OnSave) @@ -1877,18 +1877,19 @@ EVT_MENU(MainWin_IntHelp, MainWindow::OnIntegratedHelp) EVT_MENU(MainWin_ShowLog, MainWindow::OnShowDebug) -// event + // event EVT_CLOSE(MainWindow::OnClose) EVT_TIMER(MainWin_SeqTimer, MainWindow::OnTimer) EVT_TIMER(MainWin_KillTimer, MainWindow::OnKillTimer) -// button + // button EVT_BUTTON(FileLoader_Start, MainWindow::OnFileLoaderStart) EVT_BUTTON(FileLoader_Stop, MainWindow::OnFileLoaderStop) -// EVT_MENU(MainWin_OpenVideo, MainWindow::OnOpenVideo) -// EVT_MENU(MainWin_CloseVideo, MainWindow::OnCloseVideo) -// EVT_MENU(MainWin_SeekVideo, MainWindow::OnSeekVideo) + // EVT_MENU(MainWin_OpenVideo, MainWindow::OnOpenVideo) + // EVT_MENU(MainWin_CloseVideo, MainWindow::OnCloseVideo) + // EVT_MENU(MainWin_SeekVideo, MainWindow::OnSeekVideo) //EVT_TEXT_MAXLEN(101010, MainWindow::OnSetPosition) //EVT_PLAYPOSITION(313131, MainWindow::OnSetPosition) -END_EVENT_TABLE() + END_EVENT_TABLE() + Modified: branches/saveXml/src/gui/Makefile.am =================================================================== --- branches/saveXml/src/gui/Makefile.am 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/gui/Makefile.am 2006-10-27 17:09:33 UTC (rev 1119) @@ -1,6 +1,6 @@ LDFLAGS = $(shell wx-config --libs) -L/usr/pkg/lib/ `xml2-config --libs` -CPPFLAGS = $(shell wx-config --cflags) -I../audio -I../libs/WiredAkai/include -I../plugins -I../fileloader -I/opt/gnome/include -I../sequencer -I../redist -I../engine -I../mixer -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime -I../asm -I../editmidi -I../undo -I../libs/WiredWidgets/src -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags ` +CPPFLAGS = $(shell wx-config --cflags) -I../xml -I../save -I../audio -I../libs/WiredAkai/include -I../plugins -I../fileloader -I/opt/gnome/include -I../sequencer -I../redist -I../engine -I../mixer -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime -I../asm -I../editmidi -I../undo -I../libs/WiredWidgets/src -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags ` if PORTAUDIO CPPFLAGS += -I../portaudio/include Modified: branches/saveXml/src/gui/MediaLibrary.cpp =================================================================== --- branches/saveXml/src/gui/MediaLibrary.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/gui/MediaLibrary.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -44,13 +44,11 @@ #include "MainWindow.h" #include "Sequencer.h" #include "Colour.h" -#include "WiredSession.h" #include "HelpPanel.h" +#include "SaveCenter.h" -extern WiredSession *CurrentSession; -extern WiredSessionXml *CurrentXmlSession; +extern SaveCenter *saveCenter; - const struct s_combo_choice SortSelectChoices[NB_SORTSELECT_CHOICES + 1] = { { wxT("filename") , 1 }, @@ -162,14 +160,14 @@ { wxString selfile = dlg.GetSelectedFile(); - if (CurrentXmlSession->GetAudioDir().empty() == false) + if (saveCenter->getAudioDir().empty() == false) res = wxID_OK; else { wxDirDialog dir(this, _("Choose the Audio file directory"), wxFileName::GetCwd()); if (dir.ShowModal() == wxID_OK) { - CurrentXmlSession->GetAudioDir() = dir.GetPath().c_str(); + saveCenter->setAudioDir(dir.GetPath()); res = wxID_OK; } else Modified: branches/saveXml/src/gui/Transport.cpp =================================================================== --- branches/saveXml/src/gui/Transport.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/gui/Transport.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -9,7 +9,7 @@ #include "Sequencer.h" #include "SequencerGui.h" #include "Colour.h" -#include "WiredSession.h" +//#include "WiredSession.h" #include "HelpPanel.h" #include "DownButton.h" #include "HoldButton.h" @@ -18,10 +18,10 @@ #include "../engine/Settings.h" #include "../engine/AudioEngine.h" -extern WiredSession *CurrentSession; +//extern WiredSession *CurrentSession; Transport::Transport(wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, WiredDocument *docParent) - : wxPanel(parent, -1, pos, size, style) WiredDocument(wxT("transport"), docParent) + : wxPanel(parent, -1, pos, size, style), WiredDocument(wxT("transport"), docParent) { SetBackgroundColour(CL_RULER_BACKGROUND); //wxColour(204, 199, 219));//*wxLIGHT_GREY); @@ -204,27 +204,28 @@ void Transport::OnRecord(wxCommandEvent &WXUNUSED(event)) { - if (RecordBtn->GetOn()) - { - wxFileName f(CurrentSession->AudioDir.c_str()); - if (CurrentSession->AudioDir.empty() || (!f.DirExists())) - { - wxDirDialog dir(this, _("Choose the Audio file directory"), - wxFileName::GetCwd()); - if (dir.ShowModal() == wxID_OK) - { - CurrentSession->AudioDir = dir.GetPath().c_str(); - } - else - { - RecordBtn->SetOff(); - return; - } - } - Seq->Record(); - } - else - Seq->StopRecord(); + //USES WIREDSESSION +// if (RecordBtn->GetOn()) +// { +// wxFileName f(CurrentSession->AudioDir.c_str()); +// if (CurrentSession->AudioDir.empty() || (!f.DirExists())) +// { +// wxDirDialog dir(this, _("Choose the Audio file directory"), +// wxFileName::GetCwd()); +// if (dir.ShowModal() == wxID_OK) +// { +// CurrentSession->AudioDir = dir.GetPath().c_str(); +// } +// else +// { +// RecordBtn->SetOff(); +// return; +// } +// } +// Seq->Record(); +// } +// else +// Seq->StopRecord(); } void Transport::OnLoop(wxCommandEvent &WXUNUSED(event)) @@ -462,26 +463,51 @@ void Transport::Save() { - SaveElement toBeSaved; + wxString s; - toBeSaved.setKey(wxT("BPM")); - toBeSaved.setValue(Seq->BPM); + std::cerr << "[Save] Transport::Save()" << std::endl; + + SaveElement *BPM = new SaveElement(); + s.clear(); + s << Seq->BPM; + BPM->setKey(wxT("BPM")); + BPM->setValue(s); + saveDocData(WIRED_PROJECT_FILE, BPM); - toBeSaved.setKey(wxT("SigNumerator")); - toBeSaved.setValue(Seq->SigNumerator); + SaveElement *SigNum = new SaveElement(); + s.clear(); + s << Seq->SigNumerator; + SigNum->setKey(wxT("SigNumerator")); + SigNum->setValue(s); + this->saveDocData(WIRED_PROJECT_FILE, SigNum); - toBeSaved.setKey(wxT("SigDenominator")); - toBeSaved.setValue(Seq->SigDenominator); + SaveElement *SigDen = new SaveElement(); + s.clear(); + s << Seq->SigDenominator; + SigDen->setKey(wxT("SigDenominator")); + SigDen->setValue(s); + this->saveDocData(WIRED_PROJECT_FILE, SigDen); - toBeSaved.SetKey(wxT("Click")); - toBeSaved.SetValue(Seq->Click); - toBeSaved.SetKey(wxT("Loop")); - toBeSaved.SetValue(Seq->Loop); - saveDocData(WIRED_PROJECT_FILE, &toBeSaved); + SaveElement *Click = new SaveElement(); + s.clear(); + s << Seq->Click; + Click->setKey(wxT("Click")); + Click->setValue(s); + this->saveDocData(WIRED_PROJECT_FILE, Click); - + SaveElement *Loop = new SaveElement(); + s.clear(); + s << Seq->Loop; + Loop->setKey(wxT("Loop")); + Loop->setValue(s); + this->saveDocData(WIRED_PROJECT_FILE, Loop); } +void Transport::Load() +{ + +} + BEGIN_EVENT_TABLE(Transport, wxPanel) EVT_BUTTON(Transport_Play, Transport::OnPlay) EVT_BUTTON(Transport_Stop, Transport::OnStop) Modified: branches/saveXml/src/gui/Transport.h =================================================================== --- branches/saveXml/src/gui/Transport.h 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/gui/Transport.h 2006-10-27 17:09:33 UTC (rev 1119) @@ -80,6 +80,9 @@ void OnPaint(wxPaintEvent &event); void OnIdle(wxIdleEvent &WXUNUSED(event)); + void Save(); + void Load(); + protected: friend class MainWindow; Modified: branches/saveXml/src/redist/Plugin.h =================================================================== --- branches/saveXml/src/redist/Plugin.h 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/redist/Plugin.h 2006-10-27 17:09:33 UTC (rev 1119) @@ -20,6 +20,7 @@ #include <list> #include <vector> #include <map> +#include "Plugin.h" // methods are mainly in this class class Plugin; Modified: branches/saveXml/src/save/Makefile.am =================================================================== --- branches/saveXml/src/save/Makefile.am 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/save/Makefile.am 2006-10-27 17:09:33 UTC (rev 1119) @@ -1,9 +1,11 @@ LDFLAGS = $(shell wx-config --libs) -CPPFLAGS = $(shell wx-config --cflags) -I../xml/ -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags` +CPPFLAGS = $(shell wx-config --cflags) -I../xml -I/usr/pkg/include/libxml2 \ + -I/usr/pkg/include `xml2-config --cflags` noinst_LIBRARIES = libsave.a libsave_a_SOURCES = \ SaveCenter.cpp \ - WiredDocument.cpp + WiredDocument.cpp \ + ../xml/WiredXml.cpp Modified: branches/saveXml/src/save/SaveCenter.cpp =================================================================== --- branches/saveXml/src/save/SaveCenter.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/save/SaveCenter.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -2,12 +2,14 @@ SaveCenter::SaveCenter(wxString docName, wxString projectName, - WiredDocument *docParent = NULL, - wxString projectPath = wxT("")) + wxString projectPath = wxT(""), + WiredDocument *docParent = NULL) : WiredDocument(docName, docParent) { setProjectPath(projectPath); setProjectName(projectName); + _audioDir << _projectPath << wxT("/audio/"); + } SaveCenter::~SaveCenter() @@ -31,10 +33,15 @@ wxString fileName; WiredXml *xmlFile = new WiredXml(); + std::cerr << "[Save] SaveCenter::SaveProject" << std::endl; + fileName << _projectPath << _projectName << wxT(".xml"); + std::cerr << "[Save] filename = " << fileName.mb_str() << std::endl; xmlFile->CreateDocument(fileName); + std::cerr << "[Save] xmlFile created" << std::endl; + SaveDocument((WiredDocument *)this, xmlFile); xmlFile->EndDocumentWriter(); @@ -55,29 +62,48 @@ SaveElementArray *toWrite; SaveElementsHashMap::iterator saveElementsIt; + std::cerr << "[SaveCenter] SaveCenter::SaveDocument" << std::endl; + //Get our children childrenOfCurrentNode = currentNode->getChildren(); + std::cerr << "[SaveCenter] childrenOfCurrentNode" << std::endl; + //Save Document currentNode->Save(); + std::cerr << "[SaveCenter] Save" << std::endl; + //get my SaveElements saveElements = currentNode->getDocData(); + std::cerr << "[SaveCenter] getNodeData" << std::endl; + //write our SaveElements... //...start with our name... xmlFile->StartElement(currentNode->getName()); + + std::cerr << "[SaveCenter] startelement : node name = " << currentNode->getName().mb_str() << std::endl; //Write references AddReferences(saveElements, xmlFile); + std::cerr << "[SaveCenter] references added" << std::endl; + + std::cerr << "[SaveCenter] saveElements.count(WIRED_PROJECT_FILE) = " << saveElements.count(WIRED_PROJECT_FILE) << std::endl; + //get elements to write in the conf file - toWrite = saveElements[WIRED_PROJECT_FILE]; + if(saveElements.count(WIRED_PROJECT_FILE)) + { + toWrite = saveElements[WIRED_PROJECT_FILE]; + std::cerr << "[SaveCenter] toWrite" << std::endl; + + //...then write the elements + for (i = 0; i < toWrite->GetCount(); i++) + WriteElement(toWrite->Item(i), xmlFile); - //...then write the elements - for (i = 0; i < toWrite->GetCount(); i++) - WriteElement((*toWrite->Item(i)), xmlFile); - + std::cerr << "[SaveCenter] Elements written" << std::endl; + } //Write the other files for (saveElementsIt = saveElements.begin(); saveElementsIt != saveElements.end(); @@ -85,19 +111,21 @@ if(saveElementsIt->first != WIRED_PROJECT_FILE) WriteFile(saveElementsIt->first, saveElementsIt->second); + std::cerr << "[SaveCenter] other files written" << std::endl; + //call recursively on our children for (i = 0; i < childrenOfCurrentNode.GetCount(); i++) SaveDocument(childrenOfCurrentNode[i], xmlFile); //...finish by closing things - xmlFile->EndElement(); + xmlFile->EndElement(); } void SaveCenter::AddReferences(SaveElementsHashMap &saveElements, WiredXml *xmlFile) { SaveElementsHashMap::iterator saveElementsIt; - SaveElement ref; + SaveElement *ref; //for each entry of the hash map.... for (saveElementsIt = saveElements.begin(); @@ -107,23 +135,23 @@ if(saveElementsIt->first != WIRED_PROJECT_FILE) { //fill a SaveElement - ref.clear(); - ref.setPair(wxT("reference"), saveElementsIt->first); + ref->clear(); + ref->setPair(wxT("reference"), saveElementsIt->first); //and write it. WriteElement(ref, xmlFile); } } -void SaveCenter::WriteElement(SaveElement elem, WiredXml *xmlFile) +void SaveCenter::WriteElement(SaveElement *elem, WiredXml *xmlFile) { int i; AttributesHashMap attributes; AttributesHashMap::iterator attributesIt; - attributes = elem.getAttributes(); + attributes = elem->getAttributes(); //XML bullshit - xmlFile->StartElement(elem.getKey()); + xmlFile->StartElement(elem->getKey()); for(attributesIt = attributes.begin(); @@ -148,7 +176,7 @@ xmlFile->StartElement(rootTag); for (i = 0; i < elements->GetCount(); i++) - WriteElement((*elements->Item(i)), xmlFile); + WriteElement(elements->Item(i), xmlFile); xmlFile->EndElement(); delete xmlFile; @@ -160,6 +188,16 @@ return _projectPath; } +wxString SaveCenter::getAudioDir() +{ + return _audioDir; +} + +void SaveCenter::setAudioDir(wxString audioDir) +{ + _audioDir = audioDir; +} + void SaveCenter::setProjectPath(wxString projectPath) { @@ -191,3 +229,8 @@ _projectName << wxT("WiredProject"); } + +void SaveCenter::LoadProject(wxString filename) +{ + +} Modified: branches/saveXml/src/save/SaveCenter.h =================================================================== --- branches/saveXml/src/save/SaveCenter.h 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/save/SaveCenter.h 2006-10-27 17:09:33 UTC (rev 1119) @@ -7,27 +7,26 @@ class SaveCenter : public WiredDocument { public: + /** Constructor. + * \param projectName + * \param docParent + * \param projectPath + */ SaveCenter(wxString docName, - wxString projectName, - WiredDocument *docParent, - wxString projectPath); + wxString projectName, + wxString projectPath, + WiredDocument *docParent); ~SaveCenter(); /** Main Save function, implementation of WiredDocument. * The SaveCenter is a WiredDocument. This function is used to save * projectwide infos - * \param conf Please, refer to the WiredDocument class documentation. - * \param data Please, refer to the WiredDocument class documentation. - * \param filename Please, refer to the WiredDocument class documentation. */ void Save(); /** Main Load function, implementation of WiredDocument. * The SaveCenter is a WiredDocument. This function is used to load * projectwide infos - * \param conf Please, refer to the WiredDocument class documentation. - * \param data Please, refer to the WiredDocument class documentation. - * \param filename Please, refer to the WiredDocument class documentation. */ void Load(); @@ -42,6 +41,9 @@ /** Returns the project name. */ wxString getProjectName(); + wxString getAudioDir(); + void setAudioDir(wxString audioDir); + /** Sets the project name * \param projectName the new project name. */ @@ -62,13 +64,14 @@ */ void SaveFile(WiredDocument *doc, wxString file); + void LoadProject(wxString filename); private: /** Writes an element in the xmlfile. * \param elem the element to write. * \param xmlFile the WiredXml object to write in. */ - void WriteElement(SaveElement elem, WiredXml *xmlFile); + void WriteElement(SaveElement *elem, WiredXml *xmlFile); /** Saves a WiredDocument. * This function calls itself recursively, so the whole WiredDocument tree is @@ -98,6 +101,7 @@ private: wxString _projectName; wxString _projectPath; + wxString _audioDir; }; #endif /*_SAVECENTER_H_ */ Modified: branches/saveXml/src/save/WiredDocument.cpp =================================================================== --- branches/saveXml/src/save/WiredDocument.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/save/WiredDocument.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -1,5 +1,6 @@ #include "WiredDocument.h" +#include <iostream> WiredDocument::WiredDocument(wxString name, WiredDocument *parent = NULL) { //uncomment when savecenter is instanciated @@ -8,7 +9,7 @@ if(parent) parent->Register(this); - + _name = name; } @@ -31,11 +32,22 @@ void WiredDocument::saveDocData(wxString file, SaveElement *data) { - SaveElement *toAdd; + SaveElementsHashMap::iterator it; - toAdd = new SaveElement(*data); + if(!_dataSave.count(file)) + { + _dataSave[file] = new SaveElementArray(); + std::cerr << "Added key to _dataSave : " << file.mb_str() << std::endl; + } + //Should check if key already exists and delete it before overwriting it. + _dataSave[file]->Add(data); - _dataSave[file]->Add(toAdd); + std::cerr << "dumping _DataSave" << std::endl; + for(it = _dataSave.begin(); it != _dataSave.end(); it++) + { + std::cerr << it->first.mb_str() << std::endl; + } + } void WiredDocument::clearDocData() Modified: branches/saveXml/src/save/WiredDocument.h =================================================================== --- branches/saveXml/src/save/WiredDocument.h 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/save/WiredDocument.h 2006-10-27 17:09:33 UTC (rev 1119) @@ -34,7 +34,7 @@ SaveElementsHashMap getDocData(); SaveElementArray *getDocFile(wxString file); - private: + protected: void saveDocData(wxString file, SaveElement *data); void clearDocData(); void rmDocDataFile(wxString file); Modified: branches/saveXml/src/sequencer/Makefile.am =================================================================== --- branches/saveXml/src/sequencer/Makefile.am 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/sequencer/Makefile.am 2006-10-27 17:09:33 UTC (rev 1119) @@ -1,6 +1,6 @@ LDFLAGS = $(shell wx-config --libs) -L/usr/pkg/lib/ `xml2-config --libs` -CPPFLAGS = $(shell wx-config --cflags) -I../gui -I../libs/WiredAkai/include -I../plugins -I../fileloader -I/opt/gnome/include -I../audio -I../redist -I../engine -I../mixer -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime -I../asm -I../editmidi -I../undo -I.. -I../libs/WiredWidgets/src -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags` +CPPFLAGS = $(shell wx-config --cflags) -I../xml -I../save -I../gui -I../libs/WiredAkai/include -I../plugins -I../fileloader -I/opt/gnome/include -I../audio -I../redist -I../engine -I../mixer -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime -I../asm -I../editmidi -I../undo -I.. -I../libs/WiredWidgets/src -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags` if PORTAUDIO CPPFLAGS += -I../portaudio/include Modified: branches/saveXml/src/xml/Makefile.am =================================================================== --- branches/saveXml/src/xml/Makefile.am 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/xml/Makefile.am 2006-10-27 17:09:33 UTC (rev 1119) @@ -1,4 +1,4 @@ -CPPFLAGS = $(shell wx-config --cflags) -I../gui -I../plugins -I../fileloader -I/opt/gnome/include -I../sequencer -I../redist -I../audio -I../mixer -I../midi -I../midi/portmidi/pm_common -I../midi/portmidi/porttime -I../editmidi -I../undo -I../libs/WiredWidgets/src -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags` +CPPFLAGS = $(shell wx-config --cflags) -I/opt/gnome/include -I/usr/pkg/include/libxml2/ -I/usr/pkg/include `xml2-config --cflags` if PORTAUDIO CPPFLAGS += -I../portaudio/include @@ -10,8 +10,5 @@ noinst_LIBRARIES = libwiredxml.a libwiredxml_a_SOURCES = \ - ../redist/Plugin.cpp \ WiredXml.cpp \ - WiredXml.h \ - WiredSessionXml.cpp \ - WiredSessionXml.h \ No newline at end of file + WiredXml.h \ No newline at end of file Modified: branches/saveXml/src/xml/WiredSessionXml.h =================================================================== --- branches/saveXml/src/xml/WiredSessionXml.h 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/xml/WiredSessionXml.h 2006-10-27 17:09:33 UTC (rev 1119) @@ -35,7 +35,7 @@ #include "../gui/MidiPattern.h" #include "../gui/Rack.h" #include "../midi/midi.h" -#include "../gui/Transport.h" +//#include "../gui/Transport.h" #include "../engine/AudioCenter.h" //For Windows future ... Modified: branches/saveXml/src/xml/WiredXml.cpp =================================================================== --- branches/saveXml/src/xml/WiredXml.cpp 2006-10-27 16:42:10 UTC (rev 1118) +++ branches/saveXml/src/xml/WiredXml.cpp 2006-10-27 17:09:33 UTC (rev 1119) @@ -100,19 +100,32 @@ bool WiredXml::CreateDocument(const wxString& DocName) { - CloseDocumentWriter(); - if (DocName.Cmp(wxT("")) == 0) + std::cerr << "[WiredXml] CreateDocument" << std::endl; + + CloseDocumentWriter(); + std::cerr << "[WiredXml] CloseDocumentWriter" << std::endl; + + if (DocName.Cmp(wxT("")) == 0) + _DocumentWriterName = _DocumentFileName + TEMP_EXTENSION; + else + _DocumentWriterName = DocName; + + std::cerr << "[WiredXml] _DocumentWriterName = " << _DocumentWriterName.mb_str() << std::endl; + if ((_DocumentWriter = xmlNewTextWriterFilename(_DocumentWriterName.mb_str(*wxConvCurrent), 0)) != NULL) + { + std::cerr << "[WiredXml] 1" << std::endl; + if (xmlTextWriterSetIndent(_DocumentWriter, 4) == 0) { - _DocumentWriterName = _DocumentFileName + TEMP_EXTENSION; + std::cerr << "[WiredXml] 2" << std::endl; + if (xmlTextWriterStartDocument(_DocumentWriter, NULL, NULL, NULL) >= 0) + { + std::cerr << "[WiredXml] 3" << std::endl; + //if (xmlTextWriterWriteDTDExternalEntity(_DocumentWriter, FALSE, ) >= 0) + return true; + } } - else - _DocumentWriterName = DocName; - if ((_DocumentWriter = xmlNewTextWriterFilename(_DocumentWriterName.mb_str(*wxConvCurrent), 0)) != NULL) - if (xmlTextWriterSetIndent(_DocumentWriter, 4) == 0) - if (xmlTextWriterStartDocument(_DocumentWriter, NULL, NULL, NULL) >= 0) - //if (xmlTextWriterWriteDTDExternalEntity(_DocumentWriter, FALSE, ) >= 0) - return true; - return false; + } + return false; } bool WiredXml::StartElement(const wxString& Name) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |