Skip to content

Commit

Permalink
replaced main.cpp with something more interesting
Browse files Browse the repository at this point in the history
  • Loading branch information
micknoise committed Jun 18, 2015
1 parent 00a6fbc commit 4404984
Show file tree
Hide file tree
Showing 37 changed files with 82 additions and 10,925 deletions.
72 changes: 49 additions & 23 deletions main.cpp
@@ -1,35 +1,61 @@
#include "maximilian.h"

maxiOsc myCounter,mySwitchableOsc;//
maxiSample beat;
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;
//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};



void setup() {//some inits
myEnvelope.amplitude=myEnvelopeData[0]; //initialise the envelope
beat.load("/Users/mick/Documents/workspace/Maximilian/beat2.wav");

}

void play(double *output) {
void play(double *output) {//this is where the magic happens. Very slow magic.

CurrentCount=myCounter.phasor(1, 1, 9);//phasor can take three arguments; frequency, start value and end value.
currentCount=(int)timer.phasor(9);//this sets up a metronome that ticks every so often

if (CurrentCount<5)//simple if statement

myOscOutput=mySwitchableOsc.square(CurrentCount*100);
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
}

else if (CurrentCount>=5)//and the 'else' bit.

myOscOutput=mySwitchableOsc.saw(CurrentCount*50);//one osc object can produce whichever waveform you want.
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==1)

myEnvelope.trigger(0,myEnvelopeData[0]); //trigger the envelope
delayout=(leadout+(delay.dl(leadout, 14000, 0.8)*0.5))/2;//add some delay

myFilteredOutput=myFilter.lores(myOscOutput,(myEnvelope.line(6, myEnvelopeData)),10);//lores takes an audio input, a frequency and a resonance factor (1-100)
if(trigger!=0)trigger=0;//set the trigger to off if you want it to trigger immediately next time.

*output=myFilteredOutput/2+beat.play(-1.,0,beat.length);//point me at your speakers and fire.
}

output[0]=(bassout+delayout)/2;//sum output
output[1]=(bassout+delayout)/2;

}
4 changes: 2 additions & 2 deletions maximilianTest_10.8.xcodeproj/project.pbxproj
Expand Up @@ -208,7 +208,7 @@
"\"$(SRCROOT)\"",
);
PRODUCT_NAME = rtaudiotest;
SDKROOT = macosx;
SDKROOT = macosx10.9;
};
name = Debug;
};
Expand All @@ -225,7 +225,7 @@
"\"$(SRCROOT)\"",
);
PRODUCT_NAME = rtaudiotest;
SDKROOT = macosx;
SDKROOT = macosx10.9;
};
name = Release;
};
Expand Down
Expand Up @@ -11,17 +11,17 @@
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</key>
<string>ssh://github.com/micknoise/Maximilian.git</string>
<string>https://github.com/micknoise/Maximilian.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>maximilianTest_10.8.xcodeproj/project.xcworkspace</string>
<string>maximilianTest_10.8.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/micknoise/Maximilian.git</string>
<string>https://github.com/micknoise/Maximilian.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
Expand Down
Binary file not shown.
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,10 +14,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "emptyExample.app"
BlueprintName = "emptyExample"
ReferencedContainer = "container:NewStuff.xcodeproj">
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
BuildableName = "rtaudiotest"
BlueprintName = "maximilianTest"
ReferencedContainer = "container:maximilianTest_10.8.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -32,10 +32,10 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "emptyExample.app"
BlueprintName = "emptyExample"
ReferencedContainer = "container:NewStuff.xcodeproj">
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
BuildableName = "rtaudiotest"
BlueprintName = "maximilianTest"
ReferencedContainer = "container:maximilianTest_10.8.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
Expand All @@ -48,13 +48,14 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "emptyExample.app"
BlueprintName = "emptyExample"
ReferencedContainer = "container:NewStuff.xcodeproj">
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
BuildableName = "rtaudiotest"
BlueprintName = "maximilianTest"
ReferencedContainer = "container:maximilianTest_10.8.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
Expand All @@ -66,13 +67,14 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "emptyExample.app"
BlueprintName = "emptyExample"
ReferencedContainer = "container:NewStuff.xcodeproj">
BlueprintIdentifier = "8DD76F620486A84900D96B5E"
BuildableName = "rtaudiotest"
BlueprintName = "maximilianTest"
ReferencedContainer = "container:maximilianTest_10.8.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
Expand Up @@ -4,25 +4,15 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>emptyExample Debug.xcscheme_^#shared#^_</key>
<key>maximilianTest.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>emptyExample Release.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>emptyExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>E4B69B5A0A3A1756003C02F2</key>
<key>8DD76F620486A84900D96B5E</key>
<dict>
<key>primary</key>
<true/>
Expand Down
13 changes: 0 additions & 13 deletions ofxMaxim/ofxMaximExample_0.8.4_OSX/Makefile

This file was deleted.

0 comments on commit 4404984

Please sign in to comment.