Changeset 1295
- Timestamp:
- 10/30/07 01:16:02 (10 months ago)
- Location:
- trunk/src/buzelib
- Files:
-
- 7 modified
-
BuzeConfiguration.cpp (modified) (1 diff)
-
BuzeConfiguration.h (modified) (1 diff)
-
EditorActions.cpp (modified) (1 diff)
-
MainFrm.cpp (modified) (3 diffs)
-
MainFrm.h (modified) (3 diffs)
-
WaveTableList.cpp (modified) (1 diff)
-
resource.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/buzelib/BuzeConfiguration.cpp
r1290 r1295 186 186 } 187 187 188 std::string CConfiguration::getExternalWaveEditor() { 189 string cmd; 190 if (!getConfigString("Settings", "ExternalWaveEditor", &cmd)) 191 return ""; 192 return cmd; 193 } 194 195 void CConfiguration::setExternalWaveEditor(std::string cmd) { 196 setConfigString("Settings", "ExternalWaveEditor", cmd); 197 } 198 188 199 void CConfiguration::setMachineParameterVisibility(std::string uri, int parameterIndex, bool state) { 189 200 setConfigNumber("Machines\\" + (string)uri + "\\ExtMachineInfo\\Parameter" + stringFromInt(parameterIndex), "Hidden", state?1:0); -
trunk/src/buzelib/BuzeConfiguration.h
r1290 r1295 51 51 void setMachineSkinVisibility(std::string uri, bool state); 52 52 bool getMachineSkinVisibility(std::string uri); 53 54 void setExternalWaveEditor(std::string cmd); 55 std::string getExternalWaveEditor(); 56 53 57 }; -
trunk/src/buzelib/EditorActions.cpp
r1273 r1295 747 747 int numTracks=this->tracks; 748 748 749 if (numTracks< machine->loader->plugin_info->max_tracks) {749 if (numTracks<=machine->loader->plugin_info->max_tracks) { 750 750 int prevTracks = machine->getTracks(); 751 751 machine->setTracks(numTracks); -
trunk/src/buzelib/MainFrm.cpp
r1290 r1295 35 35 #include <sys/stat.h> 36 36 #include <fstream> 37 #include <win32/sndfile.h> 37 38 #include "DockTabFrame/DockTabSerializer.h" 38 39 … … 861 862 } 862 863 864 LRESULT CMainFrame::OnWaveXEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 865 assert(document->selectedWave); 866 867 int wavetableIndex = document->getWaveIndex(document->selectedWave); 868 869 // Get global settings 870 871 std::string waveEditor = _Module.configuration->getExternalWaveEditor(); 872 873 if (!waveEditor.length()) { 874 MessageBox("No wave editor specified", "Error"); 875 return 0; 876 } 877 878 char tmpPath[MAX_PATH]; 879 GetTempPath(MAX_PATH, tmpPath); 880 881 std::string tempFile = tmpPath + stringFromInt(wavetableIndex) + ".wav"; 882 883 PROCESS_INFORMATION pi; 884 STARTUPINFO si; 885 886 memset(&si,0,sizeof(si)); 887 si.cb= sizeof(si); 888 889 // Export document->selectedWave as tmpFileName 890 891 if(!exportWaveEntry(document->selectedWave, const_cast<char*>(tempFile.c_str()))) { 892 MessageBox("Unable to create temporary file", tempFile.c_str()); 893 return 0; 894 } 895 896 // Create a process for the wave editor, editing the temporary file 897 898 std::string command = "\"" + waveEditor + "\" " + tempFile; 899 char commandStr[1024]; 900 strncpy(commandStr, command.c_str(), 1024); 901 if(!CreateProcess(NULL, commandStr, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) { 902 MessageBox("Unable to spawn the external wave editor.", command.c_str()); 903 } 904 905 return 0; 906 } 907 908 LRESULT CMainFrame::OnWaveIEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 909 assert(document->selectedWave); 910 911 int wavetableIndex = document->getWaveIndex(document->selectedWave); 912 913 // Get global settings 914 915 char tmpPath[MAX_PATH]; 916 GetTempPath(MAX_PATH, tmpPath); 917 918 std::string tempFile = tmpPath + stringFromInt(wavetableIndex) + ".wav"; 919 920 // Re-Import tmpFileName into document->selectedWave 921 922 std::string originalFileName = document->selectedWave->fileName; 923 std::string originalName = document->selectedWave->name; 924 CBrowserIterator* browser; 925 926 browser = CArchiveBrowserBase::createBrowser(tempFile); 927 if (!browser) { 928 MessageBox("Unable to import the temporary wave file", tempFile.c_str()); 929 return 0; 930 } 931 932 importWaveEntry(browser, document->selectedWave); 933 browser->close(); 934 delete browser; 935 936 document->selectedWave->fileName = originalFileName; 937 document->selectedWave->name = originalName; 938 939 // This UI refresh is required as the names were reinstated 940 document->updateAllViews(0, UpdateImportWave, document->selectedWave); 941 942 if(remove(tempFile.c_str())) 943 { 944 MessageBox("Unable to delete the temporary wave file", tempFile.c_str()); 945 } 946 947 948 return 0; 949 } 950 863 951 LRESULT CMainFrame::OnWaveLevelProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { 864 952 showPropertyView(); … … 2226 2314 } 2227 2315 2316 bool CMainFrame::exportWaveEntry(zzub::wave_info_ex* entry, char *path) { 2317 zzub_wave_t* wave = (zzub_wave_t*)entry; 2318 int result = -1; 2319 int level = 0; 2320 SF_INFO sfinfo; 2321 2322 memset(&sfinfo, 0, sizeof(sfinfo)); 2323 sfinfo.samplerate = wave->get_samples_per_sec(level); 2324 sfinfo.channels = wave->get_stereo()?2:1; 2325 sfinfo.format = SF_FORMAT_WAV; 2326 if (wave->get_bits_per_sample(level) == 16) 2327 sfinfo.format |= SF_FORMAT_PCM_16; 2328 else if (wave->get_bits_per_sample(level) == 8) 2329 sfinfo.format |= SF_FORMAT_PCM_S8; 2330 else if (wave->get_bits_per_sample(level) == 24) 2331 sfinfo.format |= SF_FORMAT_PCM_24; 2332 else if (wave->get_bits_per_sample(level) == 32) 2333 sfinfo.format |= SF_FORMAT_PCM_32; 2334 else 2335 return 0; 2336 SNDFILE *sf = sf_open(path, SFM_WRITE, &sfinfo); 2337 if (!sf) 2338 return 0; 2339 zzub::wave_level* wavelevel = wave->get_level(level); 2340 sf_writef_short(sf, (const short*)wave->get_sample_ptr(level), wave->get_sample_count(level)); 2341 sf_close(sf); // so close it 2342 return 1; 2343 2344 } 2228 2345 2229 2346 bool CMainFrame::importWaveEntry(CBrowserIterator* it, wave_info_ex* entry) { -
trunk/src/buzelib/MainFrm.h
r1281 r1295 320 320 COMMAND_ID_HANDLER(ID_MACHINE_PROPERTIES, OnMachineProperties) 321 321 COMMAND_ID_HANDLER(ID_WAVE_PROPERTIES, OnWaveProperties) 322 COMMAND_ID_HANDLER(ID_WAVE_XEDIT, OnWaveXEdit) 323 COMMAND_ID_HANDLER(ID_WAVE_IEDIT, OnWaveIEdit) 322 324 COMMAND_ID_HANDLER(ID_WAVELEVEL_PROPERTIES, OnWaveLevelProperties) 323 325 COMMAND_ID_HANDLER(ID_WAVELEVEL_ADD, OnWaveLevelAdd) … … 400 402 LRESULT OnMachineProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 401 403 LRESULT OnWaveProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 404 LRESULT OnWaveXEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 405 LRESULT OnWaveIEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 402 406 LRESULT OnWaveLevelProperties(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); 403 407 LRESULT OnWaveLevelAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); … … 560 564 // wave table editing 561 565 bool importWaveEntry(CBrowserIterator* , zzub::wave_info_ex* entry); 566 bool exportWaveEntry(zzub::wave_info_ex* entry, char *path); 562 567 563 568 void mixdownSong(zzub::metaplugin* plugin, zzub::metaplugin* rec); -
trunk/src/buzelib/WaveTableList.cpp
r1293 r1295 123 123 view->mainFrame->document->selectWave(wave); 124 124 menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_WAVE_PROPERTIES, "Properties"); 125 menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_WAVE_XEDIT, "Export And Open With External Editor"); 126 menu.InsertMenu(-1, MF_BYPOSITION|MF_STRING, (UINT_PTR)ID_WAVE_IEDIT, "Re-Import"); 125 127 126 128 ClientToScreen(&pt); -
trunk/src/buzelib/resource.h
r1289 r1295 398 398 #define ID_EDIT_STEP_8 53432 399 399 #define ID_EDIT_STEP_9 53433 400 #define ID_WAVE_XEDIT 53434 401 #define ID_WAVE_IEDIT 53435 400 402 401 403 // Next default values for new objects
