From 51dcc8fe07ac57070754a631eb63788cac9dc438 Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Thu, 26 Jul 2012 18:02:23 +0100 Subject: copying changes back --- maximilian.cpp | 55 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'maximilian.cpp') diff --git a/maximilian.cpp b/maximilian.cpp index ed2b1f6..b0f94a3 100644 --- a/maximilian.cpp +++ b/maximilian.cpp @@ -39,10 +39,12 @@ * Uncomment the following to include Sean Barrett's Ogg Vorbis decoder. * If you're on windows, make sure to add the files std_vorbis.c and std_vorbis.h to your project*/ -//#define VORBIS +#define VORBIS #ifdef VORBIS -#include "stb_vorbis.h" +extern "C" { + #include "stb_vorbis.h" +} #endif //This used to be important for dealing with multichannel playback @@ -372,13 +374,14 @@ bool maxiSample::load(string fileName, int channel) { return read(); } -bool maxiSample::loadOgg(char *fileName, int channel) { +bool maxiSample::loadOgg(string fileName, int channel) { #ifdef VORBIS bool result; - result=fileName; readChannel=channel; int channelx; - myDataSize = stb_vorbis_decode_filename(fileName, &channelx, &temp); + cout << fileName << endl; + myDataSize = stb_vorbis_decode_filename(const_cast(fileName.c_str()), &channelx, &temp); + result = myDataSize > 0; printf("\nchannels = %d\nlength = %d",channelx,myDataSize); printf("\n"); myChannels=(short)channelx; @@ -457,6 +460,7 @@ bool maxiSample::read() length=myDataSize*(0.5/myChannels); inFile.close(); // close the input file + cout << "Ch: " << myChannels << ", len: " << length << endl; if (myChannels>1) { int position=0; int channel=readChannel*2; @@ -468,6 +472,8 @@ bool maxiSample::read() } temp = (short*) malloc(myDataSize * sizeof(char)); memcpy(temp, myData, myDataSize * sizeof(char)); + + free(myData); }else { // cout << "ERROR: Could not load sample: " <threshold && attackphase!=1){ holdcount=0; releasephase=0; @@ -938,7 +948,7 @@ double maxiDyn::gate(double input, double threshold, long holdtime, double attac if (releasephase==1 && amplitude>0.) { output=input*(amplitude*=release); - + } return output; @@ -1012,7 +1022,7 @@ double maxiEnv::ar(double input, double attack, double release, long holdtime, i holdphase=0; releasephase=1; } - + if (releasephase==1 && amplitude>0.) { output=input*(amplitude*=release); @@ -1075,10 +1085,11 @@ double maxiEnv::adsr(double input, double attack, double decay, double sustain, } double convert::mtof(int midinote) { - + return mtofarray[midinote]; } + void maxiEnvelopeFollower::setAttack(double attackMS) { attack = pow( 0.01, 1.0 / ( attackMS * maxiSettings::sampleRate * 0.001 ) ); } -- cgit v1.3