commit d1aa85b31256e1e9a68d6345f841b856e6a3157a
parent ac2119f6c8b9acf0f003f28b32de7ca0e08aea51
Author: paulnasca <paulnasca>
Date: Wed, 2 Jan 2008 13:41:17 +0000
*** empty log message ***
Diffstat:
16 files changed, 195 insertions(+), 102 deletions(-)
diff --git a/src/Effects/EffectMgr.C b/src/Effects/EffectMgr.C
@@ -44,8 +44,8 @@ EffectMgr::EffectMgr(int insertion_,pthread_mutex_t *mutex_){
EffectMgr::~EffectMgr(){
if (efx!=NULL) delete (efx);
- delete (efxoutl);
- delete (efxoutr);
+ delete []efxoutl;
+ delete []efxoutr;
};
void EffectMgr::defaults(){
@@ -65,7 +65,7 @@ void EffectMgr::changeeffect(int nefx_){
efxoutr[i]=0.0;
};
- if (efx!=NULL) delete (efx);
+ if (efx!=NULL) delete efx;
switch (nefx){
case 1:efx=new Reverb(insertion,efxoutl,efxoutr);break;
case 2:efx=new Echo(insertion,efxoutl,efxoutr);break;
diff --git a/src/Effects/Reverb.C b/src/Effects/Reverb.C
@@ -74,7 +74,7 @@ Reverb::Reverb(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_){
Reverb::~Reverb(){
int i;
- if (idelay!=NULL) delete idelay;
+ if (idelay!=NULL) delete []idelay;
if (hpf!=NULL) delete hpf;
if (lpf!=NULL) delete lpf;
@@ -235,7 +235,7 @@ void Reverb::setidelay(unsigned char Pidelay){
this->Pidelay=Pidelay;
delay=pow(50*Pidelay/127.0,2)-1.0;
- if (idelay!=NULL) delete (idelay);
+ if (idelay!=NULL) delete []idelay;
idelay=NULL;
idelaylen=(int) (SAMPLE_RATE*delay/1000);
@@ -307,7 +307,7 @@ void Reverb::settype(unsigned char Ptype){
comblen[i]=(int) tmp;
combk[i]=0;
lpcomb[i]=0;
- if (comb[i]!=NULL) delete comb[i];
+ if (comb[i]!=NULL) delete []comb[i];
comb[i]=new REALTYPE[comblen[i]];
};
@@ -320,7 +320,7 @@ void Reverb::settype(unsigned char Ptype){
if (tmp<10) tmp=10;
aplen[i]=(int) tmp;
apk[i]=0;
- if (ap[i]!=NULL) delete ap[i];
+ if (ap[i]!=NULL) delete []ap[i];
ap[i]=new REALTYPE[aplen[i]];
};
settime(Ptime);
diff --git a/src/Makefile b/src/Makefile
@@ -3,7 +3,7 @@ include Makefile.inc
ifneq ($(MAKECMDGOALS),debug)
CXXFLAGS= -O6 -Wall
else
- CXXFLAGS= -O0 -Wall -Wpointer-arith
+ CXXFLAGS= -O0 -Wall -Wpointer-arith -ggdb
endif
CXXFLAGS += -DOS_$(OS_PORT) -D$(MIDIIN)MIDIIN -DFFTW_VERSION_$(FFTW_VERSION) -DASM_F2I_$(ASM_F2I)
diff --git a/src/Misc/Bank.C b/src/Misc/Bank.C
@@ -68,8 +68,8 @@ Bank::Bank(){
Bank::~Bank(){
for (int i=0;i<MAX_NUM_BANKS;i++){
- if (banks[i].dir!=NULL) delete (banks[i].dir);
- if (banks[i].name!=NULL) delete (banks[i].name);
+ if (banks[i].dir!=NULL) delete []banks[i].dir;
+ if (banks[i].name!=NULL) delete []banks[i].name;
};
clearbank();
@@ -124,7 +124,7 @@ void Bank::setname(unsigned int ninstrument,const char *newname,int newslot){
// printf("rename %s -> %s\n",ins[ninstrument].filename,newfilename);//////////////
rename(ins[ninstrument].filename,newfilename);
- if (ins[ninstrument].filename) delete(ins[ninstrument].filename);
+ if (ins[ninstrument].filename) delete []ins[ninstrument].filename;
ins[ninstrument].filename=new char[strlen(newfilename)+5];
snprintf(ins[ninstrument].filename,strlen(newfilename)+1,"%s",newfilename);
snprintf(ins[ninstrument].name,PART_MAX_NAME_LEN,"%s",&tmpfilename[5]);
@@ -193,7 +193,7 @@ void Bank::savetoslot(unsigned int ninstrument,Part *part){
part->saveXML(filename);
addtobank(ninstrument,tmpfilename,(char *) part->Pname);
- delete(filename);
+ delete[]filename;
};
/*
@@ -220,7 +220,7 @@ int Bank::loadbank(const char *bankdirname){
if (dir==NULL) return(-1);
- if (dirname!=NULL) delete(dirname);
+ if (dirname!=NULL) delete[]dirname;
dirname=new char[strlen(bankdirname)+1];
snprintf(dirname,strlen(bankdirname)+1,"%s",bankdirname);
@@ -371,8 +371,8 @@ int Bank_compar(const void *a,const void *b){
void Bank::rescanforbanks(){
for (int i=0;i<MAX_NUM_BANKS;i++){
- if (banks[i].dir!=NULL) delete (banks[i].dir);
- if (banks[i].name!=NULL) delete (banks[i].name);
+ if (banks[i].dir!=NULL) delete []banks[i].dir;
+ if (banks[i].name!=NULL) delete []banks[i].name;
banks[i].dir=NULL;
banks[i].name=NULL;
};
@@ -405,13 +405,13 @@ void Bank::rescanforbanks(){
char *tmpname=banks[i].name;
banks[i].name=new char[strlen(tmpname)+100];
sprintf(banks[i].name,"%s[%d]",tmpname,dupl+2);
- delete(tmpname);
+ delete[]tmpname;
if (dupl==0){
char *tmpname=banks[j].name;
banks[j].name=new char[strlen(tmpname)+100];
sprintf(banks[j].name,"%s[1]",tmpname);
- delete(tmpname);
+ delete[]tmpname;
};
dupl++;
@@ -493,7 +493,7 @@ void Bank::scanrootdir(char *rootdir){
void Bank::clearbank(){
for (int i=0;i<BANK_SIZE;i++) deletefrombank(i);
- if (dirname!=NULL) delete(dirname);
+ if (dirname!=NULL) delete[]dirname;
bankfiletitle=NULL;
dirname=NULL;
};
@@ -535,7 +535,7 @@ int Bank::addtobank(int pos, const char *filename, const char* name){
xml->checkfileinformation(ins[pos].filename);
ins[pos].info.PADsynth_used=xml->information.PADsynth_used;
- delete(xml);
+ delete xml;
} else ins[pos].info.PADsynth_used=false;
return(0);
@@ -552,7 +552,7 @@ void Bank::deletefrombank(int pos){
ins[pos].used=false;
ZERO(ins[pos].name,PART_MAX_NAME_LEN+1);
if (ins[pos].filename!=NULL) {
- delete (ins[pos].filename);
+ delete []ins[pos].filename;
ins[pos].filename=NULL;
};
diff --git a/src/Misc/XMLwrapper.C b/src/Misc/XMLwrapper.C
@@ -124,7 +124,7 @@ bool XMLwrapper::checkfileinformation(char *filename){
char *end=strstr(xmldata,"</INFORMATION>");
if ((start==NULL)||(end==NULL)||(start>end)) {
- delete(xmldata);
+ delete []xmldata;
return(false);
};
end+=strlen("</INFORMATION>");
@@ -133,7 +133,7 @@ bool XMLwrapper::checkfileinformation(char *filename){
tree=mxmlNewElement(MXML_NO_PARENT,"?xml");
node=root=mxmlLoadString(tree,xmldata,MXML_OPAQUE_CALLBACK);
if (root==NULL) {
- delete(xmldata);
+ delete []xmldata;
mxmlDelete(tree);
node=root=tree=NULL;
return(false);
@@ -143,7 +143,7 @@ bool XMLwrapper::checkfileinformation(char *filename){
push(root);
if (root==NULL){
- delete(xmldata);
+ delete []xmldata;
mxmlDelete(tree);
node=root=tree=NULL;
return(false);
@@ -153,7 +153,7 @@ bool XMLwrapper::checkfileinformation(char *filename){
exitbranch();
if (tree!=NULL) mxmlDelete(tree);
- delete(xmldata);
+ delete []xmldata;
node=root=tree=NULL;
return(true);
@@ -174,8 +174,8 @@ int XMLwrapper::saveXMLfile(char *filename){
int result=dosavefile(filenamenew,compression,xmldata);
- delete(filenamenew);
- delete(xmldata);
+ delete []filenamenew;
+ delete []xmldata;
return(result);
};
@@ -273,7 +273,7 @@ int XMLwrapper::loadXMLfile(const char *filename){
root=tree=mxmlLoadString(NULL,xmldata,MXML_OPAQUE_CALLBACK);
- delete(xmldata);
+ delete []xmldata;
if (tree==NULL) return(-2);//this is not XML
diff --git a/src/Output/DSSIaudiooutput.C b/src/Output/DSSIaudiooutput.C
@@ -22,7 +22,7 @@
//this file contains code used from trivial_synth.c from
//the DSSI (published by Steve Harris under public domain) as a template
-
+//the code is incomplete
#include <string.h>
#include "DSSIaudiooutput.h"
diff --git a/src/Output/Makefile b/src/Output/Makefile
@@ -1,6 +1,6 @@
include ../Makefile.inc
-objects=Recorder.o
+objects=Recorder.o WAVaudiooutput.o
ifeq ($(AUDIOOUT),OSS_AND_JACK)
objects+=OSSaudiooutput.o JACKaudiooutput.o
diff --git a/src/Output/Recorder.C b/src/Output/Recorder.C
@@ -31,15 +31,15 @@
#include <errno.h>
#include "Recorder.h"
+#include <sys/stat.h>
Recorder::Recorder(){
recordbuf_16bit=new short int [SOUND_BUFFER_SIZE*2];
- status=0;file=-1;
- sampleswritten=0;
+ status=0;
notetrigger=0;
- for (int i=0;i<SOUND_BUFFER_SIZE*2;i++){
- recordbuf_16bit[i]=0;
- };
+ for (int i=0;i<SOUND_BUFFER_SIZE*2;i++){
+ recordbuf_16bit[i]=0;
+ };
};
Recorder::~Recorder(){
@@ -48,19 +48,20 @@ Recorder::~Recorder(){
};
int Recorder::preparefile(char *filename_,int overwrite){
- if (overwrite==0) file=open(filename_,O_CREAT|O_EXCL|O_WRONLY|O_BINARY,00444+00222);
- else file=open(filename_,O_CREAT|O_WRONLY|O_TRUNC|O_BINARY,00444+00222);//overwrite if the file exists
- if (file==-1) {
- if (errno==EEXIST) return(1);//file exists already
- else return(2);//Access Denied or any other problem
- };
+ if (!overwrite){
+ struct stat fileinfo;
+ int statr;
+
+ statr = stat(filename_,&fileinfo);
+ if(statr == 0) {//file exists
+ return 1;
+ };
+ };
+
+ if (!wav.newfile(filename_, SAMPLE_RATE)) return 2;
+
status=1;//ready
- //prepare the space fot the wav header
- //the header itself, will be written when the file is closed
- unsigned char zerobuf[44]; for (int i=0;i<44;i++) zerobuf[i]=0;
- write(file,zerobuf,44);
-
return(0);
};
@@ -70,37 +71,8 @@ void Recorder::start(){
};
void Recorder::stop(){
- unsigned int chunksize;
- lseek(file,0,SEEK_SET);
-
- write(file,"RIFF",4);
- chunksize=sampleswritten*4+36;
- write(file,&chunksize,4);
-
- write(file,"WAVEfmt ",8);
- chunksize=16;
- write(file,&chunksize,4);
- unsigned short int formattag=1;//uncompresed wave
- write(file,&formattag,2);
- unsigned short int nchannels=2;//stereo
- write(file,&nchannels,2);
- unsigned int samplerate=SAMPLE_RATE;//samplerate
- write(file,&samplerate,4);
- unsigned int bytespersec=SAMPLE_RATE*4;//bytes/sec
- write(file,&bytespersec,4);
- unsigned short int blockalign=4;//2 channels * 16 bits/8
- write(file,&blockalign,2);
- unsigned short int bitspersample=16;
- write(file,&bitspersample,2);
-
- write(file,"data",4);
- chunksize=sampleswritten*blockalign;
- write(file,&chunksize,4);
-
- close(file);
- file=-1;
+ wav.close();
status=0;
- sampleswritten=0;
};
void Recorder::pause(){
@@ -113,24 +85,20 @@ int Recorder::recording(){
};
void Recorder::recordbuffer(REALTYPE *outl,REALTYPE *outr){
- int tmp;
- if (status!=2) return;
- for (int i=0;i<SOUND_BUFFER_SIZE;i++){
- tmp=(int)(outl[i]*32767.0);
- if (tmp<-32768) tmp=-32768;
- if (tmp>32767) tmp=32767;
- recordbuf_16bit[i*2]=tmp;
-
- tmp=(int)(outr[i]*32767.0);
- if (tmp<-32768) tmp=-32768;
- if (tmp>32767) tmp=32767;
- recordbuf_16bit[i*2+1]=tmp;
- };
- if (write(file,recordbuf_16bit,SOUND_BUFFER_SIZE*4)<SOUND_BUFFER_SIZE*4) {
- fprintf(stderr,"Error while recording !\n");
- stop();
+ int tmp;
+ if (status!=2) return;
+ for (int i=0;i<SOUND_BUFFER_SIZE;i++){
+ tmp=(int)(outl[i]*32767.0);
+ if (tmp<-32768) tmp=-32768;
+ if (tmp>32767) tmp=32767;
+ recordbuf_16bit[i*2]=tmp;
+
+ tmp=(int)(outr[i]*32767.0);
+ if (tmp<-32768) tmp=-32768;
+ if (tmp>32767) tmp=32767;
+ recordbuf_16bit[i*2+1]=tmp;
};
- sampleswritten+=SOUND_BUFFER_SIZE;
+ wav.write(SOUND_BUFFER_SIZE,recordbuf_16bit);
};
void Recorder::triggernow(){
diff --git a/src/Output/Recorder.h b/src/Output/Recorder.h
@@ -24,6 +24,7 @@
#define RECORDER_H
#include "../globals.h"
+#include "WAVaudiooutput.h"
class Recorder{
public:
@@ -44,9 +45,9 @@ class Recorder{
int status;
private:
- int file;
+ WAVaudiooutput wav;
short int *recordbuf_16bit;
- int sampleswritten,notetrigger;
+ int notetrigger;
};
#endif
diff --git a/src/Output/WAVaudiooutput.C b/src/Output/WAVaudiooutput.C
@@ -0,0 +1,84 @@
+/*
+ Copyright (C) 2006 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ 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 <stdio.h>
+#include <stdlib.h>
+#include "WAVaudiooutput.h"
+using namespace std;
+
+WAVaudiooutput::WAVaudiooutput(){
+ file=NULL;
+ sampleswritten=0;
+ samplerate=44100;
+};
+
+WAVaudiooutput::~WAVaudiooutput(){
+ close();
+};
+
+bool WAVaudiooutput::newfile(string filename,int samplerate){
+ close();//inchide un posibil fisier existent
+ file=fopen(filename.c_str(),"w");
+ if (!file) return false;
+ this->samplerate=samplerate;
+ sampleswritten=0;
+ char tmp[44];
+ fwrite(tmp,1,44,file);
+ return(true);
+};
+
+void WAVaudiooutput::close(){
+ 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=2;//stereo
+ fwrite(&nchannels,2,1,file);
+ unsigned int samplerate_=samplerate;//samplerate
+ fwrite(&samplerate_,4,1,file);
+ unsigned int bytespersec=samplerate*4;//bytes/sec
+ fwrite(&bytespersec,4,1,file);
+ unsigned short int blockalign=4;//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;
+ };
+};
+
+void WAVaudiooutput::write(int nsmps,short int *smps){
+ if (!file) return;
+ fwrite(smps,nsmps,4,file);
+ sampleswritten+=nsmps;
+};
+
diff --git a/src/Output/WAVaudiooutput.h b/src/Output/WAVaudiooutput.h
@@ -0,0 +1,40 @@
+/*
+
+ Copyright (C) 2008 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ 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 WAVOUTPUT_H
+#define WAVOUTPUT_H
+#include <string>
+#include <stdio.h>
+
+class WAVaudiooutput{
+ public:
+ WAVaudiooutput();
+ ~WAVaudiooutput();
+
+ bool newfile(std::string filename,int samplerate);
+ void close();
+
+ void write(int nsmps, short int *smps);
+
+ private:
+ int sampleswritten;
+ int samplerate;
+ FILE *file;
+};
+#endif
diff --git a/src/Params/PADnoteParameters.C b/src/Params/PADnoteParameters.C
@@ -131,7 +131,7 @@ void PADnoteParameters::defaults(){
void PADnoteParameters::deletesample(int n){
if ((n<0)||(n>=PAD_MAX_SAMPLES)) return;
if (sample[n].smp!=NULL){
- delete(sample[n].smp);
+ delete[]sample[n].smp;
sample[n].smp=NULL;
};
sample[n].size=0;
diff --git a/src/Synth/ADnote.C b/src/Synth/ADnote.C
@@ -404,7 +404,7 @@ void ADnote::ADlegatonote(REALTYPE freq, REALTYPE velocity, int portamento_, int
*/
void ADnote::KillVoice(int nvoice){
- delete (NoteVoicePar[nvoice].OscilSmp);
+ delete []NoteVoicePar[nvoice].OscilSmp;
if (NoteVoicePar[nvoice].FreqEnvelope!=NULL) delete(NoteVoicePar[nvoice].FreqEnvelope);
NoteVoicePar[nvoice].FreqEnvelope=NULL;
@@ -433,7 +433,7 @@ void ADnote::KillVoice(int nvoice){
if (NoteVoicePar[nvoice].FMAmpEnvelope!=NULL) delete (NoteVoicePar[nvoice].FMAmpEnvelope);
NoteVoicePar[nvoice].FMAmpEnvelope=NULL;
- if ((NoteVoicePar[nvoice].FMEnabled!=NONE)&&(NoteVoicePar[nvoice].FMVoice<0)) delete NoteVoicePar[nvoice].FMSmp;
+ if ((NoteVoicePar[nvoice].FMEnabled!=NONE)&&(NoteVoicePar[nvoice].FMVoice<0)) delete []NoteVoicePar[nvoice].FMSmp;
if (NoteVoicePar[nvoice].VoiceOut!=NULL)
for (int i=0;i<SOUND_BUFFER_SIZE;i++) NoteVoicePar[nvoice].VoiceOut[i]=0.0;//do not delete, yet: perhaps is used by another voice
diff --git a/src/UI/ConfigUI.fl b/src/UI/ConfigUI.fl
@@ -108,7 +108,7 @@ config.cfg.SoundBufferSize=strtoul(o->value(),&tmp,10);}
tooltip {Internal Sound Buffer Size (samples)} xywh {190 45 60 20} type Int labelsize 11 align 129 textfont 1
code0 {char *tmpbuf=new char[100];o->cut(0,o->maximum_size());}
code1 {snprintf(tmpbuf,100,"%d",config.cfg.SoundBufferSize);o->insert(tmpbuf);}
- code2 {delete(tmpbuf);}
+ code2 {delete []tmpbuf;}
}
Fl_Light_Button {} {
label {Swap Stereo }
@@ -435,7 +435,7 @@ return(order);} {}
samplerateinput->cut(0,samplerateinput->maximum_size());
snprintf(tmpbuf,100,"%d",config.cfg.SampleRate);
samplerateinput->insert(tmpbuf);
-delete (tmpbuf);} {}
+delete []tmpbuf;} {}
}
Function {show()} {} {
code {configwindow->show();} {}
diff --git a/src/UI/MicrotonalUI.fl b/src/UI/MicrotonalUI.fl
@@ -225,7 +225,7 @@ for (int i=0;i<microtonal->getoctavesize();i++){
tuningsinput->insert(tmpbuf);
};
-delete(tmpbuf);} {}
+delete []tmpbuf;} {}
}
Function {updateMappingInput()} {} {
code {char *tmpbuf=new char[100];
@@ -240,7 +240,7 @@ for (int i=0;i<microtonal->Pmapsize;i++){
mappinginput->insert(tmpbuf);
};
-delete(tmpbuf);} {}
+delete []tmpbuf;} {}
}
Function {MicrotonalUI(Microtonal *microtonal_)} {} {
code {microtonal=microtonal_;
diff --git a/src/main.C b/src/main.C
@@ -384,7 +384,7 @@ int main(int argc, char *argv[]){
#ifdef JACKAUDIOOUT
usejackit=true;//use jack by default
#endif
- fprintf(stderr,"%s","\nZynAddSubFX - Copyright (c) 2002-2007 Nasca Octavian Paul and others\n");
+ fprintf(stderr,"%s","\nZynAddSubFX - Copyright (c) 2002-2008 Nasca Octavian Paul and others\n");
fprintf(stderr,"Compiled: %s %s\n",__DATE__,__TIME__);
fprintf(stderr,"%s","This program is free software (GNU GPL v.2 or later) and \n it comes with ABSOLUTELY NO WARRANTY.\n\n");
#ifdef OS_LINUX