zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 3ef70a684f330a58c2d8ba041be8d07b4883333e
parent 3d831f31c101110cd4c23041b1087baeae35b08f
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Wed, 30 Dec 2009 20:54:32 -0500

Nio: Removing Input and Output dirs from cmake

- The cmake system should no longer depend on the old Input Output folders
- The folders are currently still in place, as not all drivers are fully
  integrated

Diffstat:
Msrc/CMakeLists.txt | 15+--------------
Msrc/Misc/CMakeLists.txt | 3++-
Asrc/Misc/WavFile.cpp | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/Misc/WavFile.h | 43+++++++++++++++++++++++++++++++++++++++++++
Msrc/Params/CMakeLists.txt | 2+-
Msrc/Params/PADnoteParameters.cpp | 9++++-----
Msrc/main.cpp | 39+++------------------------------------
7 files changed, 147 insertions(+), 57 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -68,7 +68,6 @@ endif() if(AlsaEnable) list(APPEND AUDIO_LIBRARIES ${ASOUND_LIBRARY}) add_definitions(-DALSA=1) - add_definitions(-DALSAMIDIIN=1) #alsa midi TEMPORARY endif(AlsaEnable) if(JackEnable) @@ -88,12 +87,6 @@ if(PaEnable) list(APPEND AUDIO_LIBRARIES ${PORTAUDIO_LIBRARIES}) endif() - -if(AlsaMidiOutput) - add_definitions(-DOSSAUDIOOUT) - set(AUDIO_LIBRARIES ${AUDIO_LIBRARIES} ${ASOUND_LIBRARY}) -endif() - if (CompileTests) ENABLE_TESTING() endif() @@ -204,13 +197,11 @@ macro(unit_test NAME CXX_FILE FILES) endmacro(unit_test) set(NONGUI_LIBRARIES - zynaddsubfx_input zynaddsubfx_misc zynaddsubfx_synth zynaddsubfx_seq zynaddsubfx_effect zynaddsubfx_params - zynaddsubfx_output zynaddsubfx_dsp zynaddsubfx_samples zynaddsubfx_controls @@ -218,13 +209,10 @@ set(NONGUI_LIBRARIES ) set(CXXTEST_LINK_LIBS ${NONGUI_LIBRARIES}) -set(MIDIINPUT_LIBRARIES "") add_subdirectory(Misc) -add_subdirectory(Input) add_subdirectory(Controls) add_subdirectory(Synth) -add_subdirectory(Output) add_subdirectory(Seq) add_subdirectory(Effects) add_subdirectory(Params) @@ -249,7 +237,6 @@ target_link_libraries(zynaddsubfx ${MXML_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} - ${MIDIINPUT_LIBRARIES} - ${OS_LIBRARIES} + ${OS_LIBRARIES} ) diff --git a/src/Misc/CMakeLists.txt b/src/Misc/CMakeLists.txt @@ -10,10 +10,11 @@ set(zynaddsubfx_misc_SRCS Util.cpp XMLwrapper.cpp Recorder.cpp + WavFile.cpp ) add_library(zynaddsubfx_misc STATIC ${zynaddsubfx_misc_SRCS} ) -target_link_libraries(zynaddsubfx_misc zynaddsubfx_nio zynaddsubfx_output) +target_link_libraries(zynaddsubfx_misc zynaddsubfx_nio) diff --git a/src/Misc/WavFile.cpp b/src/Misc/WavFile.cpp @@ -0,0 +1,93 @@ +/* + Copyright (C) 2006 Nasca Octavian Paul + Author: Nasca Octavian Paul + Mark McCurry + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <cstdio> +#include <cstdlib> +#include "WavFile.h" +using namespace std; + +WavFile::WavFile(string filename, int samplerate, int channels) + :sampleswritten(0), samplerate(samplerate), channels(channels), + file(fopen(filename.c_str(), "w")) + +{ + if(file) { + //making space for the header written at destruction + char tmp[44]; + memset(tmp, 0, 44*sizeof(char)); + fwrite(tmp, 1, 44, file); + } +} + +WavFile::~WavFile() +{ + if(file) { + unsigned int chunksize; + rewind(file); + + fwrite("RIFF", 4, 1, file); + chunksize = sampleswritten * 4 + 36; + fwrite(&chunksize, 4, 1, file); + + fwrite("WAVEfmt ", 8, 1, file); + chunksize = 16; + fwrite(&chunksize, 4, 1, file); + unsigned short int formattag = 1; //uncompresed wave + fwrite(&formattag, 2, 1, file); + unsigned short int nchannels = channels; //stereo + fwrite(&nchannels, 2, 1, file); + unsigned int samplerate_ = samplerate; //samplerate + fwrite(&samplerate_, 4, 1, file); + unsigned int bytespersec = samplerate * 2 * channels; //bytes/sec + fwrite(&bytespersec, 4, 1, file); + unsigned short int blockalign = 2 * channels; //2 channels * 16 bits/8 + fwrite(&blockalign, 2, 1, file); + unsigned short int bitspersample = 16; + fwrite(&bitspersample, 2, 1, file); + + fwrite("data", 4, 1, file); + chunksize = sampleswritten * blockalign; + fwrite(&chunksize, 4, 1, file); + + fclose(file); + file = NULL; + } +} + +bool WavFile::good() const +{ + return NULL != file; +} + +void WavFile::writeStereoSamples(int nsmps, short int *smps) +{ + if(file) { + fwrite(smps, nsmps, 4, file); + sampleswritten += nsmps; + } +} + +void WavFile::writeMonoSamples(int nsmps, short int *smps) +{ + if(file) { + fwrite(smps, nsmps, 2, file); + sampleswritten += nsmps; + } +} + diff --git a/src/Misc/WavFile.h b/src/Misc/WavFile.h @@ -0,0 +1,43 @@ +/* + + Copyright (C) 2008 Nasca Octavian Paul + Author: Nasca Octavian Paul + Mark McCurry + + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef WAVFILE_H +#define WAVFILE_H +#include <string> + +class WavFile +{ + public: + WavFile(std::string filename, int samplerate, int channels); + ~WavFile(); + + bool good() const; + + void writeMonoSamples(int nsmps, short int *smps); + void writeStereoSamples(int nsmps, short int *smps); + + private: + int sampleswritten; + int samplerate; + int channels; + FILE *file; +}; +#endif + diff --git a/src/Params/CMakeLists.txt b/src/Params/CMakeLists.txt @@ -16,4 +16,4 @@ add_library(zynaddsubfx_params STATIC ${zynaddsubfx_params_SRCS} ) -target_link_libraries(zynaddsubfx_params)# ${ASOUND_LIBRARY}) +target_link_libraries(zynaddsubfx_params zynaddsubfx_misc) diff --git a/src/Params/PADnoteParameters.cpp b/src/Params/PADnoteParameters.cpp @@ -21,7 +21,7 @@ */ #include <math.h> #include "PADnoteParameters.h" -#include "../Output/WAVaudiooutput.h" +#include "../Misc/WavFile.h" using namespace std; PADnoteParameters::PADnoteParameters(FFTwrapper *fft_, @@ -676,14 +676,13 @@ void PADnoteParameters::export2wav(string basefilename) char tmpstr[20]; snprintf(tmpstr, 20, "_%02d", k + 1); string filename = basefilename + string(tmpstr) + ".wav"; - WAVaudiooutput wav; - if(wav.newfile(filename, SAMPLE_RATE, 1)) { + WavFile wav(filename, SAMPLE_RATE, 1); + if(wav.good()) { int nsmps = sample[k].size; short int *smps = new short int[nsmps]; for(int i = 0; i < nsmps; i++) smps[i] = (short int)(sample[k].smp[i] * 32767.0); - wav.write_mono_samples(nsmps, smps); - wav.close(); + wav.writeMonoSamples(nsmps, smps); } } } diff --git a/src/main.cpp b/src/main.cpp @@ -44,27 +44,6 @@ extern Dump dump; #include "Nio/InMgr.h" #include "Nio/EngineMgr.h" -#warning TODO remove conditional include block -#if 0 -#include "Input/MidiIn.h" - -#ifdef ALSAMIDIIN -#include "Input/ALSAMidiIn.h" -#endif - -#ifdef OSSMIDIIN -#include "Input/OSSMidiIn.h" -#endif - -#if (defined(NONEMIDIIN) || (defined(VSTMIDIIN))||(!ALSAMIDIIN && !OSSMIDIIN)) -#include "Input/NULLMidiIn.h" -#endif - -#ifdef WINMIDIIN -#include "Input/WINMidiIn.h" -#endif -#endif - #ifndef DISABLE_GUI #ifdef QT_GUI @@ -96,7 +75,6 @@ bool usejackit = false; LASHClient *lash; #endif -MidiIn *Midi; int Pexitprogram = 0; //if the UI set this to 1, the program will exit /* @@ -214,16 +192,6 @@ void initprogram() master = new Master(); master->swaplr = swaplr; -#if 0 -#if defined(ALSAMIDIIN) - Midi = new ALSAMidiIn(); -#elif defined(OSSMIDIIN) - Midi = new OSSMidiIn(); -#else // defined(NONEMIDIIN) || (defined(VSTMIDIIN)) - Midi = new NULLMidiIn(); -#endif -#endif - //Nio Initialization //Enable input wrapper @@ -257,13 +225,12 @@ void exitprogram() delete sysEngine; #ifndef DISABLE_GUI - delete (ui); + delete ui; #endif - delete (Midi); - delete (master); + delete master; #ifdef USE_LASH - delete (lash); + delete lash; #endif // pthread_mutex_unlock(&master->mutex);