-
Notifications
You must be signed in to change notification settings - Fork 0
/
AwesomeSynth.mm
55 lines (48 loc) · 1.18 KB
/
AwesomeSynth.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// AwesomeSynth.mm
// awesomesauce
//
// Created by Ravi Parikh on 2/13/11.
// Copyright 2011 AwesomeBox. All rights reserved.
//
#import "AwesomeSynth.h"
#import "SineWave.h"
#import "BlitSquare.h"
#import "BlitSaw.h"
AwesomeSynth::AwesomeSynth(int inInstType, int inFreq, int inInstClass) {
setInstrument(inInstType, inFreq, inInstClass);
}
void AwesomeSynth::setInstrument(int inInst, int inFreq, int inInstClass) {
instrument = inInst;
instClass = inInstClass;
frequency = inFreq;
char fileName[15];
if(instClass == 0) {
sprintf(fileName, "s%d-%d", instrument, frequency); //synth class
}
else {
sprintf(fileName, "d%d-%d", instrument, frequency); //drum class
}
wavFile = new MoAudioFileIn();
wavFile->bufferSize = 1024 * 1024;
wavFile->openFile(fileName, "wav", false, true);
NSLog(@"buffer size: %d\n", wavFile->bufferSize);
}
int AwesomeSynth::getInst() {
return instrument;
}
int AwesomeSynth::getFrequency() {
return frequency;
}
StkFloat AwesomeSynth::tick() {
StkFloat tick_val = 0.0;
int num = 3;
for(int i = 0; i < 3; i++) {
SAMPLE tempS = wavFile->tick();
tick_val += tempS;
}
return tick_val / num;
}
void AwesomeSynth::reset() {
wavFile->reset();
}