aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormick <mickgrierson@gmail.com>2014-10-15 10:14:02 +0100
committermick <mickgrierson@gmail.com>2014-10-15 10:14:02 +0100
commitbbe04a0f9254e81ca6be8a23164fb3e8743e6c82 (patch)
treed47bf6cbc9d23da2f41c15da94a8977fe1d10218
parenta38ec23a22a45f7fd902f97e5fe38c9f1a7fb6e6 (diff)
bug fixes that I should have done last year
arg
-rwxr-xr-xmain.cpp70
-rw-r--r--maximilian.cpp12
-rwxr-xr-xmaximilianTest.xcodeproj/project.pbxproj6
-rw-r--r--maximilianTest.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest.xccheckout10
-rw-r--r--maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstatebin0 -> 33130 bytes
-rw-r--r--maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/maximilianTest.xcscheme86
-rw-r--r--maximilianTest.xcodeproj/xcuserdata/mick.xcuserdatad/xcschemes/xcschememanagement.plist22
-rw-r--r--maximilianTest_10.8.xcodeproj/project.xcworkspace/xcshareddata/maximilianTest_10.8.xccheckout10
-rw-r--r--maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstatebin31076 -> 52300 bytes
9 files changed, 151 insertions, 65 deletions
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 @@
<string>maximilianTest</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
- <key>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</key>
+ <key>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</key>
<string>ssh://github.com/micknoise/Maximilian.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>maximilianTest.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
- <key>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</key>
+ <key>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/micknoise/Maximilian.git</string>
<key>IDESourceControlProjectVersion</key>
- <integer>110</integer>
+ <integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
- <string>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</string>
+ <string>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
- <string>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</string>
+ <string>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</string>
<key>IDESourceControlWCCName</key>
<string>Maximilian</string>
</dict>
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
--- /dev/null
+++ b/maximilianTest.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate
Binary files 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0600"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DD76F620486A84900D96B5E"
+ BuildableName = "rtaudiotest"
+ BlueprintName = "maximilianTest"
+ ReferencedContainer = "container:maximilianTest.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DD76F620486A84900D96B5E"
+ BuildableName = "rtaudiotest"
+ BlueprintName = "maximilianTest"
+ ReferencedContainer = "container:maximilianTest.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DD76F620486A84900D96B5E"
+ BuildableName = "rtaudiotest"
+ BlueprintName = "maximilianTest"
+ ReferencedContainer = "container:maximilianTest.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "8DD76F620486A84900D96B5E"
+ BuildableName = "rtaudiotest"
+ BlueprintName = "maximilianTest"
+ ReferencedContainer = "container:maximilianTest.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SchemeUserState</key>
+ <dict>
+ <key>maximilianTest.xcscheme</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>8DD76F620486A84900D96B5E</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>
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 @@
<string>maximilianTest_10.8</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
- <key>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</key>
+ <key>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</key>
<string>ssh://github.com/micknoise/Maximilian.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>maximilianTest_10.8.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
- <key>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</key>
+ <key>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/micknoise/Maximilian.git</string>
<key>IDESourceControlProjectVersion</key>
- <integer>110</integer>
+ <integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
- <string>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</string>
+ <string>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
- <string>FEC4E512-E134-4CF0-895B-9FCE9B4F273E</string>
+ <string>9EA75D55FA54A28D61D05E99737654AEBBBF0FB9</string>
<key>IDESourceControlWCCName</key>
<string>Maximilian</string>
</dict>
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
--- a/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/maximilianTest_10.8.xcodeproj/project.xcworkspace/xcuserdata/mick.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ