From bbe04a0f9254e81ca6be8a23164fb3e8743e6c82 Mon Sep 17 00:00:00 2001 From: mick Date: Wed, 15 Oct 2014 10:14:02 +0100 Subject: bug fixes that I should have done last year arg --- main.cpp | 70 +++++------------ maximilian.cpp | 12 +-- maximilianTest.xcodeproj/project.pbxproj | 6 ++ .../xcshareddata/maximilianTest.xccheckout | 10 +-- .../UserInterfaceState.xcuserstate | Bin 0 -> 33130 bytes .../xcschemes/maximilianTest.xcscheme | 86 +++++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 22 ++++++ .../xcshareddata/maximilianTest_10.8.xccheckout | 10 +-- .../UserInterfaceState.xcuserstate | Bin 31076 -> 52300 bytes 9 files changed, 151 insertions(+), 65 deletions(-) create mode 100644 maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/maximilianTest.xcscheme create mode 100644 maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/main.cpp b/main.cpp index 6ac7cdf..60b2b6e 100755 --- a/main.cpp +++ b/main.cpp @@ -1,61 +1,33 @@ #include "maximilian.h" -//Bizarelly, this sounds a little bit like Kraftwerk's 'Metropolis', although it isn't. Funny that. - -maxiOsc sound,bass,timer,mod,lead,lead2,leadmod;//here are the synth bits -maxiEnv envelope, leadenvelope;//some envelopes -maxiFilter filter, filter2;//some filters -maxiDelayline delay;//a delay -convert mtof;//a method for converting midi notes to frequency -double bassout,leadout, delayout;//some variables to hold the data and pass it around -int trigger, trigger2, newnote;//some control variables -int currentCount,lastCount,playHead=0, currentChord=0;//some other control variables -int pitch[8]={57,57,59,60};//the bassline for the arpeggio -int chord[8]={0,0,7,2,5,5,0,0};//the root chords for the arpeggio -float currentPitch,leadPitch;//the final pitch variables - -//here's the lead line trigger array, followed by the pitches -int leadLineTrigger[256]={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -int leadLinePitch[15]={69,67,65,64,67,66,64,62,65,64,62,57,55,60,57}; - - +maxiOsc myCounter,mySwitchableOsc;// +int CurrentCount;// +double myOscOutput,myFilteredOutput;// +double myEnvelopeData[6] = {500,0,1000,500,0,500};//this data will be used to make an envelope. Value and time to value in ms. +maxiEnvelope myEnvelope; +maxiFilter myFilter; void setup() {//some inits - + myEnvelope.amplitude=myEnvelopeData[0]; //initialise the envelope } -void play(double *output) {//this is where the magic happens. Very slow magic. - - currentCount=(int)timer.phasor(9);//this sets up a metronome that ticks every so often +void play(double *output) { - if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound - trigger=1;//play the arpeggiator line - trigger2=leadLineTrigger[playHead%256];//play the lead line - if (trigger2==1) {//if we are going to play a note - leadPitch=mtof.mtof(leadLinePitch[newnote]);//get the next pitch val - newnote++;//and iterate - if (newnote>14) { - newnote=0;//make sure we don't go over the edge of the array - } - } - currentPitch=mtof.mtof(pitch[(playHead%4)]+chord[currentChord%8]);//write the frequency val into currentPitch - playHead++;//iterate the playhead - if (playHead%32==0) {//wrap every 4 bars - currentChord++;//change the chord - } - //cout << "tick\n";//the clock ticks - lastCount=0;//set lastCount to 0 - } + CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value. - bassout=filter2.lores(envelope.adsr(bass.saw(currentPitch*0.5)+sound.pulse(currentPitch*0.5,mod.phasor(1)),1,0.9995, 0.25, 0.9995, 1, trigger),9250,2);//new, simple ADSR. - leadout=filter.lores(leadenvelope.ar(lead2.saw(leadPitch*4)+lead.pulse(leadPitch+(leadmod.sinebuf(1.9)*1.5), 0.6), 0.00005, 0.999975, 50000, trigger2),5900,10);//leadline + if (CurrentCount<5)//simple if statement + + myOscOutput=mySwitchableOsc.square(CurrentCount*100); - delayout=(leadout+(delay.dl(leadout, 14000, 0.8)*0.5))/2;//add some delay + else if (CurrentCount>=5)//and the 'else' bit. + + myOscOutput=mySwitchableOsc.saw(CurrentCount*50);//one osc object can produce whichever waveform you want. - if(trigger!=0)trigger=0;//set the trigger to off if you want it to trigger immediately next time. + if (CurrentCount==1) + + myEnvelope.trigger(0,myEnvelopeData[0]); //trigger the envelope + myFilteredOutput=myFilter.lores(myOscOutput,(myEnvelope.line(6, myEnvelopeData)),10);//lores takes an audio input, a frequency and a resonance factor (1-100) - output[0]=(bassout+delayout)/2;//sum output - output[1]=(bassout+delayout)/2; - -} \ No newline at end of file + *output=myFilteredOutput;//point me at your speakers and fire. +} diff --git a/maximilian.cpp b/maximilian.cpp index e89a8b7..eff0fe8 100644 --- a/maximilian.cpp +++ b/maximilian.cpp @@ -368,7 +368,7 @@ double maxiEnvelope::line(int numberofsegments,double segments[1000]) { //This is a basic multi-segment ramp generator that you can use for more or less anything. //However, it's not that intuitive. if (isPlaying==1) {//only make a sound once you've been triggered - period=2./(segments[valindex+1]*0.004); + period=4./(segments[valindex+1]*0.0044); nextval=segments[valindex+2]; currentval=segments[valindex]; if (currentval-amplitude > 0.0000001 && valindex < numberofsegments) { @@ -440,9 +440,9 @@ double maxiFilter::hipass(double input, double cutoff) { } //awesome. cuttof is freq in hz. res is between 1 and whatever. Watch out! double maxiFilter::lores(double input,double cutoff1, double resonance) { - cutoff=cutoff1*0.5; + cutoff=cutoff1; if (cutoff<10) cutoff=10; - if (cutoff>(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5); + if (cutoff>(maxiSettings::sampleRate)) cutoff=(maxiSettings::sampleRate); if (resonance<1.) resonance = 1.; z=cos(TWOPI*cutoff/maxiSettings::sampleRate); c=2-2*z; @@ -456,9 +456,9 @@ double maxiFilter::lores(double input,double cutoff1, double resonance) { //working hires filter double maxiFilter::hires(double input,double cutoff1, double resonance) { - cutoff=cutoff1*0.5; + cutoff=cutoff1; if (cutoff<10) cutoff=10; - if (cutoff>(maxiSettings::sampleRate*0.5)) cutoff=(maxiSettings::sampleRate*0.5); + if (cutoff>(maxiSettings::sampleRate)) cutoff=(maxiSettings::sampleRate); if (resonance<1.) resonance = 1.; z=cos(TWOPI*cutoff/maxiSettings::sampleRate); c=2-2*z; @@ -1202,7 +1202,7 @@ double maxiEnv::ar(double input, double attack, double release, long holdtime, i return output; } -/* and here's a new adsr. It's not bad, very simple to use*/ +/* adsr. It's not bad, very simple to use*/ double maxiEnv::adsr(double input, double attack, double decay, double sustain, double release, long holdtime, int trigger) { diff --git a/maximilianTest.xcodeproj/project.pbxproj b/maximilianTest.xcodeproj/project.pbxproj index 1c3367a..19a3759 100755 --- a/maximilianTest.xcodeproj/project.pbxproj +++ b/maximilianTest.xcodeproj/project.pbxproj @@ -149,6 +149,8 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + }; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "maximilianTest" */; compatibilityVersion = "Xcode 3.1"; developmentRegion = English; @@ -188,6 +190,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD)"; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -204,6 +207,7 @@ "\"$(SRCROOT)\"", ); PRODUCT_NAME = rtaudiotest; + SDKROOT = macosx; }; name = Debug; }; @@ -211,6 +215,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_MODEL_TUNING = G5; INSTALL_PATH = /usr/local/bin; @@ -220,6 +225,7 @@ "\"$(SRCROOT)\"", ); PRODUCT_NAME = rtaudiotest; + SDKROOT = macosx; }; name = Release; }; diff --git a/maximilianTest.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest.xccheckout b/maximilianTest.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest.xccheckout index 5e97a5f..b636a35 100644 --- a/maximilianTest.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest.xccheckout +++ b/maximilianTest.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest.xccheckout @@ -10,29 +10,29 @@ maximilianTest IDESourceControlProjectOriginsDictionary - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 ssh://github.com/micknoise/Maximilian.git IDESourceControlProjectPath maximilianTest.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 ../.. IDESourceControlProjectURL ssh://github.com/micknoise/Maximilian.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 IDESourceControlWCCName Maximilian diff --git a/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate b/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..34021e4 Binary files /dev/null and b/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/maximilianTest.xcscheme b/maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/maximilianTest.xcscheme new file mode 100644 index 0000000..77003ee --- /dev/null +++ b/maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/maximilianTest.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/xcschememanagement.plist b/maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..f2cc5e9 --- /dev/null +++ b/maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + maximilianTest.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 8DD76F620486A84900D96B5E + + primary + + + + + diff --git a/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest_10.8.xccheckout b/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest_10.8.xccheckout index 34979c6..7c68a24 100644 --- a/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest_10.8.xccheckout +++ b/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest_10.8.xccheckout @@ -10,29 +10,29 @@ maximilianTest_10.8 IDESourceControlProjectOriginsDictionary - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 ssh://github.com/micknoise/Maximilian.git IDESourceControlProjectPath maximilianTest_10.8.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 ../.. IDESourceControlProjectURL ssh://github.com/micknoise/Maximilian.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - FEC4E512-E134-4CF0-895B-9FCE9B4F273E + 9EA75D55FA54A28D61D05E99737654AEBBBF0FB9 IDESourceControlWCCName Maximilian diff --git a/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate b/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate index 68b1965..a4e927b 100644 Binary files a/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate and b/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate differ -- cgit v1.3