zynaddsubfx

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

commit 11f3961a3a362544b876c2427a6f058dd068b556
parent d1aa85b31256e1e9a68d6345f841b856e6a3157a
Author: paulnasca <paulnasca>
Date:   Wed,  2 Jan 2008 14:19:29 +0000

*** empty log message ***

Diffstat:
MChangeLog | 8++++++++
Msrc/Effects/Distorsion.h | 2+-
Msrc/Makefile | 4++--
Msrc/Output/Recorder.C | 2+-
Msrc/Output/WAVaudiooutput.C | 9+++++----
Msrc/Output/WAVaudiooutput.h | 3++-
Msrc/Params/PADnoteParameters.C | 22++++++++++++++++++++++
Msrc/Params/PADnoteParameters.h | 3++-
Msrc/UI/PADnoteUI.fl | 153+++++++++++++++++++++++++++++++++++++++++++------------------------------------
9 files changed, 127 insertions(+), 79 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -822,5 +822,13 @@ 01 Apr 2007 - O mica modificare cu xclass zynaddsubfx in MasterUI.fl 09 Sep 2007 - Schimbata licenta la GPL 2 or other later +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + +02 Ian 2008 - Corectate cateva mici erori la dezalocarea memoriei + - Codul de recorder wav a fost rescris + - Adaugata functia de export la sample-urile din PADsynth + + + diff --git a/src/Effects/Distorsion.h b/src/Effects/Distorsion.h @@ -47,7 +47,7 @@ class Distorsion:public Effect{ unsigned char Ppanning;//Panning unsigned char Plrcross;// L/R Mixing unsigned char Pdrive; //the input amplification - unsigned char Plevel; //the ouput amplification + unsigned char Plevel; //the output amplification unsigned char Ptype; //Distorsion type unsigned char Pnegate; //if the input is negated unsigned char Plpf; //lowpass filter diff --git a/src/Makefile b/src/Makefile @@ -3,10 +3,10 @@ include Makefile.inc ifneq ($(MAKECMDGOALS),debug) CXXFLAGS= -O6 -Wall else - CXXFLAGS= -O0 -Wall -Wpointer-arith -ggdb + CXXFLAGS= -O0 -Wall -Wpointer-arith endif -CXXFLAGS += -DOS_$(OS_PORT) -D$(MIDIIN)MIDIIN -DFFTW_VERSION_$(FFTW_VERSION) -DASM_F2I_$(ASM_F2I) +CXXFLAGS += -DOS_$(OS_PORT) -D$(MIDIIN)MIDIIN -DFFTW_VERSION_$(FFTW_VERSION) -DASM_F2I_$(ASM_F2I) -ggdb ifeq ($(DISABLE_GUI),YES) CXXFLAGS += -DDISABLE_GUI diff --git a/src/Output/Recorder.C b/src/Output/Recorder.C @@ -58,7 +58,7 @@ int Recorder::preparefile(char *filename_,int overwrite){ }; }; - if (!wav.newfile(filename_, SAMPLE_RATE)) return 2; + if (!wav.newfile(filename_, SAMPLE_RATE,2)) return 2; status=1;//ready diff --git a/src/Output/WAVaudiooutput.C b/src/Output/WAVaudiooutput.C @@ -31,11 +31,12 @@ WAVaudiooutput::~WAVaudiooutput(){ close(); }; -bool WAVaudiooutput::newfile(string filename,int samplerate){ +bool WAVaudiooutput::newfile(string filename,int samplerate,int channels){ close();//inchide un posibil fisier existent file=fopen(filename.c_str(),"w"); if (!file) return false; this->samplerate=samplerate; + this->channels=channels; sampleswritten=0; char tmp[44]; fwrite(tmp,1,44,file); @@ -56,13 +57,13 @@ void WAVaudiooutput::close(){ fwrite(&chunksize,4,1,file); unsigned short int formattag=1;//uncompresed wave fwrite(&formattag,2,1,file); - unsigned short int nchannels=2;//stereo + 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*4;//bytes/sec + unsigned int bytespersec=samplerate*2*channels;//bytes/sec fwrite(&bytespersec,4,1,file); - unsigned short int blockalign=4;//2 channels * 16 bits/8 + 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); diff --git a/src/Output/WAVaudiooutput.h b/src/Output/WAVaudiooutput.h @@ -27,7 +27,7 @@ class WAVaudiooutput{ WAVaudiooutput(); ~WAVaudiooutput(); - bool newfile(std::string filename,int samplerate); + bool newfile(std::string filename,int samplerate,int channels); void close(); void write(int nsmps, short int *smps); @@ -35,6 +35,7 @@ class WAVaudiooutput{ private: int sampleswritten; int samplerate; + int channels; FILE *file; }; #endif diff --git a/src/Params/PADnoteParameters.C b/src/Params/PADnoteParameters.C @@ -21,6 +21,8 @@ */ #include <math.h> #include "PADnoteParameters.h" +#include "../Output/WAVaudiooutput.h" +using namespace std; PADnoteParameters::PADnoteParameters(FFTwrapper *fft_,pthread_mutex_t *mutex_):Presets(){ setpresettype("Ppadsyth"); @@ -534,6 +536,26 @@ void PADnoteParameters::applyparameters(bool lockmutex){ }; }; +void PADnoteParameters::export2wav(string basefilename){ + applyparameters(true); + basefilename+="_PADsynth_"; + for (int k=0;k<PAD_MAX_SAMPLES;k++){ + if (sample[k].smp==NULL) continue; + char tmpstr[20]; + snprintf(tmpstr,20,"_%02d",k); + string filename=basefilename+string(tmpstr)+".wav"; + WAVaudiooutput wav; + if (wav.newfile(filename,SAMPLE_RATE,1)) { + 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(nsmps, smps); + wav.close(); + }; + }; +}; + + void PADnoteParameters::add2XML(XMLwrapper *xml){ xml->information.PADsynth_used=true; diff --git a/src/Params/PADnoteParameters.h b/src/Params/PADnoteParameters.h @@ -34,7 +34,7 @@ #include "LFOParams.h" #include "FilterParams.h" #include "Presets.h" - +#include <string> class PADnoteParameters:public Presets{ public: @@ -143,6 +143,7 @@ class PADnoteParameters:public Presets{ REALTYPE getNhr(int n);//gets the n-th overtone position relatively to N harmonic void applyparameters(bool lockmutex); + void export2wav(std::string basefilename); OscilGen *oscilgen; Resonance *resonance; diff --git a/src/UI/PADnoteUI.fl b/src/UI/PADnoteUI.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0106 +version 1.0107 header_name {.h} code_name {.cc} decl {\#include "../Params/PADnoteParameters.h"} {public @@ -20,6 +20,9 @@ decl {\#include <FL/Fl_Box.H>} {public decl {\#include <FL/Fl_Group.H>} {public } +decl {\#include <FL/Fl_File_Chooser.H>} {public +} + decl {\#include <math.h>} {} decl {\#include <stdio.h>} {} @@ -223,8 +226,8 @@ make_window();} {} Function {make_window()} {open } { Fl_Window padnotewindow { - label {PAD synth Parameters} selected - xywh {76 165 535 450} type Double hide + label {PAD synth Parameters} open + xywh {281 302 535 450} type Double visible } { Fl_Tabs {} { callback {if (o->value()!=harmonicstructuregroup) applybutton->hide(); @@ -256,15 +259,15 @@ cbwidget->do_callback();} xywh {15 45 75 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10 code0 {o->value(pars->Php.base.type);} } { - menuitem {} { + MenuItem {} { label Gauss xywh {15 15 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Square xywh {25 25 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label DoubleExp xywh {35 35 100 20} labelfont 1 labelsize 10 } @@ -307,19 +310,19 @@ cbwidget->do_callback();} xywh {15 175 70 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10 code0 {o->value(pars->Php.amp.type);} } { - menuitem {} { + MenuItem {} { label OFF xywh {45 45 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Gauss xywh {55 55 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Sine xywh {65 65 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Flat xywh {75 75 100 20} labelfont 1 labelsize 10 } @@ -332,19 +335,19 @@ cbwidget->do_callback();} xywh {15 205 70 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10 code0 {o->value(pars->Php.amp.mode);} } { - menuitem {} { + MenuItem {} { label Sum xywh {60 60 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Mult xywh {70 70 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Div1 xywh {80 80 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label Div2 xywh {90 90 100 20} labelfont 1 labelsize 10 } @@ -383,15 +386,15 @@ cbwidget->do_callback();} xywh {10 143 80 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10 code0 {o->value(pars->Php.onehalf);} } { - menuitem {} { + MenuItem {} { label Full xywh {25 25 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label {Upper Half} xywh {45 45 100 20} labelfont 1 labelsize 10 } - menuitem {} { + MenuItem {} { label {Lower Half} xywh {35 35 100 20} labelfont 1 labelsize 10 } @@ -457,31 +460,31 @@ cbwidget->do_callback();} xywh {325 310 80 20} down_box BORDER_BOX labelsize 10 align 5 textsize 11 code0 {o->value(pars->Phrpos.type);} } { - menuitem {} { + MenuItem {} { label Harmonic xywh {70 70 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label ShiftU xywh {80 80 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label ShiftL xywh {90 90 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label PowerU xywh {90 90 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label PowerL xywh {100 100 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Sine xywh {110 110 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Power xywh {120 120 100 20} labelfont 1 labelsize 11 } @@ -522,35 +525,35 @@ cbwidget->do_callback();} code0 {o->value(pars->Pbwscale);} code1 {if (pars->Pmode!=0) o->deactivate();} } { - menuitem {} { + MenuItem {} { label Normal xywh {95 95 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label EqualHz xywh {105 105 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Quater xywh {115 115 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Half xywh {125 125 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label {75%} xywh {135 135 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label {150%} xywh {145 145 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Double xywh {145 145 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label {Inv.Half} xywh {155 155 100 20} labelfont 1 labelsize 11 } @@ -567,31 +570,31 @@ cbwidget->do_callback();} xywh {375 190 115 20} down_box BORDER_BOX labelsize 10 align 5 textsize 11 code0 {o->value(pars->Pquality.samplesize);} } { - menuitem {} { + MenuItem {} { label {16k (Tiny)} xywh {155 155 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 32k xywh {165 165 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label {64k (Small)} xywh {175 175 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 128k xywh {185 185 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label {256k (Normal)} xywh {205 205 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 512k xywh {200 200 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label {1M (Big)} xywh {205 205 100 20} labelfont 1 labelsize 11 } @@ -603,31 +606,31 @@ cbwidget->do_callback();} xywh {430 155 45 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11 code0 {o->value(pars->Pquality.smpoct);} } { - menuitem {} { + MenuItem {} { label {0.5} xywh {10 10 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 1 xywh {0 0 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 2 xywh {10 10 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 3 xywh {20 20 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 4 xywh {30 30 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 6 xywh {40 40 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 12 xywh {50 50 100 20} labelfont 1 labelsize 11 } @@ -639,35 +642,35 @@ cbwidget->do_callback();} xywh {480 155 45 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11 code0 {o->value(pars->Pquality.oct);} } { - menuitem {} { + MenuItem {} { label 1 xywh {10 10 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 2 xywh {20 20 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 3 xywh {30 30 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 4 xywh {40 40 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 5 xywh {50 50 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 6 xywh {60 60 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 7 xywh {70 70 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label 8 xywh {80 80 100 20} labelfont 1 labelsize 11 } @@ -679,39 +682,39 @@ cbwidget->do_callback();} xywh {375 155 50 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11 code0 {o->value(pars->Pquality.basenote);} } { - menuitem {} { + MenuItem {} { label {C-2} xywh {10 10 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {G-2} xywh {20 20 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {C-3} xywh {20 20 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {G-3} xywh {30 30 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {C-4} xywh {30 30 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {G-4} xywh {40 40 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {C-5} xywh {40 40 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {G-5} xywh {50 50 100 20} labelfont 1 } - menuitem {} { + MenuItem {} { label {G-6} xywh {60 60 100 20} labelfont 1 } @@ -747,20 +750,20 @@ if (pars->Pmode==0){ }; cbwidget->do_callback();} - xywh {220 305 90 20} down_box BORDER_BOX labelfont 1 labelsize 10 labelcolor 0 align 5 textsize 11 + xywh {220 305 90 20} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 11 code0 {o->value(pars->Pmode);} } { - menuitem {} { + MenuItem {} { label Bandwidth xywh {105 105 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Discrete - xywh {125 125 100 20} labelfont 1 labelsize 11 labelcolor 0 + xywh {125 125 100 20} labelfont 1 labelsize 11 } - menuitem {} { + MenuItem {} { label Continous - xywh {115 115 100 20} labelfont 1 labelsize 11 labelcolor 0 + xywh {115 115 100 20} labelfont 1 labelsize 11 } } } @@ -971,6 +974,18 @@ if (resui!=NULL) { callback {presetsui->paste(pars,this);} xywh {270 430 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7 } + Fl_Button {} { + label export + callback {char *filename; +filename=fl_file_chooser("Export samples:","(*.wav)",NULL,0); +if (filename==NULL) return; +fl_filename_setext(filename,""); + + + +pars->export2wav(filename);} selected + tooltip {export samples as wav file} xywh {240 405 55 15} box THIN_UP_BOX color 255 labelsize 11 align 128 + } } } Function {refresh()} {} {