Skip to content

Commit 6daf9e9

Browse files
committedOct 28, 2012
init
1 parent bc06d6b commit 6daf9e9

22 files changed

+3094
-1565
lines changed
 

‎.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
*.xcodeproj/*
3+
!*.xcodeproj/project.pbxproj
4+
**/*.xcodeproj/*
5+
!**/*.xcodeproj/project.pbxproj
6+
!*.xcodeproj/default.*
7+
!**/*.xcodeproj/default.*
8+
*.xcworkspace/*
9+
!*.xcworkspace/contents.xcworkspacedata

‎SynthDemo.xcodeproj/project.pbxproj

+68
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
85E18DF9163D11C3001DFF48 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85E18DD6163D11C3001DFF48 /* Cocoa.framework */; };
1919
85E18E01163D11C3001DFF48 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 85E18DFF163D11C3001DFF48 /* InfoPlist.strings */; };
2020
85E18E04163D11C4001DFF48 /* SynthDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E03163D11C4001DFF48 /* SynthDemoTests.m */; };
21+
85E18E0F163D11F2001DFF48 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85E18E0D163D11F2001DFF48 /* AudioToolbox.framework */; };
22+
85E18E10163D11F2001DFF48 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85E18E0E163D11F2001DFF48 /* AudioUnit.framework */; };
23+
85E18E12163D11FA001DFF48 /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 85E18E11163D11FA001DFF48 /* CoreMIDI.framework */; };
24+
85E18E27163D13AF001DFF48 /* ADSR.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E17163D13AF001DFF48 /* ADSR.m */; };
25+
85E18E28163D13AF001DFF48 /* BiquadFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E19163D13AF001DFF48 /* BiquadFilter.m */; };
26+
85E18E29163D13AF001DFF48 /* Oscillator.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E1C163D13AF001DFF48 /* Oscillator.m */; };
27+
85E18E2A163D13AF001DFF48 /* Player.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E1E163D13AF001DFF48 /* Player.m */; };
28+
85E18E2B163D13AF001DFF48 /* SawtoothGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E20163D13AF001DFF48 /* SawtoothGenerator.m */; };
29+
85E18E2C163D13AF001DFF48 /* SineGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E22163D13AF001DFF48 /* SineGenerator.m */; };
30+
85E18E2D163D13AF001DFF48 /* SquareGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E24163D13AF001DFF48 /* SquareGenerator.m */; };
31+
85E18E2E163D13AF001DFF48 /* WhitenoiseGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E26163D13AF001DFF48 /* WhitenoiseGenerator.m */; };
32+
85E18E38163D161B001DFF48 /* PlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 85E18E37163D161B001DFF48 /* PlayerController.m */; };
2133
/* End PBXBuildFile section */
2234

2335
/* Begin PBXContainerItemProxy section */
@@ -51,13 +63,38 @@
5163
85E18E00163D11C3001DFF48 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
5264
85E18E02163D11C4001DFF48 /* SynthDemoTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SynthDemoTests.h; sourceTree = "<group>"; };
5365
85E18E03163D11C4001DFF48 /* SynthDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SynthDemoTests.m; sourceTree = "<group>"; };
66+
85E18E0D163D11F2001DFF48 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
67+
85E18E0E163D11F2001DFF48 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
68+
85E18E11163D11FA001DFF48 /* CoreMIDI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMIDI.framework; path = System/Library/Frameworks/CoreMIDI.framework; sourceTree = SDKROOT; };
69+
85E18E16163D13AF001DFF48 /* ADSR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ADSR.h; sourceTree = "<group>"; };
70+
85E18E17163D13AF001DFF48 /* ADSR.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADSR.m; sourceTree = "<group>"; };
71+
85E18E18163D13AF001DFF48 /* BiquadFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BiquadFilter.h; sourceTree = "<group>"; };
72+
85E18E19163D13AF001DFF48 /* BiquadFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BiquadFilter.m; sourceTree = "<group>"; };
73+
85E18E1A163D13AF001DFF48 /* Generator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Generator.h; sourceTree = "<group>"; };
74+
85E18E1B163D13AF001DFF48 /* Oscillator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Oscillator.h; sourceTree = "<group>"; };
75+
85E18E1C163D13AF001DFF48 /* Oscillator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Oscillator.m; sourceTree = "<group>"; };
76+
85E18E1D163D13AF001DFF48 /* Player.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Player.h; sourceTree = "<group>"; };
77+
85E18E1E163D13AF001DFF48 /* Player.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Player.m; sourceTree = "<group>"; };
78+
85E18E1F163D13AF001DFF48 /* SawtoothGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SawtoothGenerator.h; sourceTree = "<group>"; };
79+
85E18E20163D13AF001DFF48 /* SawtoothGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SawtoothGenerator.m; sourceTree = "<group>"; };
80+
85E18E21163D13AF001DFF48 /* SineGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SineGenerator.h; sourceTree = "<group>"; };
81+
85E18E22163D13AF001DFF48 /* SineGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SineGenerator.m; sourceTree = "<group>"; };
82+
85E18E23163D13AF001DFF48 /* SquareGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SquareGenerator.h; sourceTree = "<group>"; };
83+
85E18E24163D13AF001DFF48 /* SquareGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SquareGenerator.m; sourceTree = "<group>"; };
84+
85E18E25163D13AF001DFF48 /* WhitenoiseGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WhitenoiseGenerator.h; sourceTree = "<group>"; };
85+
85E18E26163D13AF001DFF48 /* WhitenoiseGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WhitenoiseGenerator.m; sourceTree = "<group>"; };
86+
85E18E36163D161B001DFF48 /* PlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerController.h; sourceTree = "<group>"; };
87+
85E18E37163D161B001DFF48 /* PlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayerController.m; sourceTree = "<group>"; };
5488
/* End PBXFileReference section */
5589

5690
/* Begin PBXFrameworksBuildPhase section */
5791
85E18DCF163D11C3001DFF48 /* Frameworks */ = {
5892
isa = PBXFrameworksBuildPhase;
5993
buildActionMask = 2147483647;
6094
files = (
95+
85E18E12163D11FA001DFF48 /* CoreMIDI.framework in Frameworks */,
96+
85E18E0F163D11F2001DFF48 /* AudioToolbox.framework in Frameworks */,
97+
85E18E10163D11F2001DFF48 /* AudioUnit.framework in Frameworks */,
6198
85E18DD7163D11C3001DFF48 /* Cocoa.framework in Frameworks */,
6299
);
63100
runOnlyForDeploymentPostprocessing = 0;
@@ -96,6 +133,9 @@
96133
85E18DD5163D11C3001DFF48 /* Frameworks */ = {
97134
isa = PBXGroup;
98135
children = (
136+
85E18E11163D11FA001DFF48 /* CoreMIDI.framework */,
137+
85E18E0D163D11F2001DFF48 /* AudioToolbox.framework */,
138+
85E18E0E163D11F2001DFF48 /* AudioUnit.framework */,
99139
85E18DD6163D11C3001DFF48 /* Cocoa.framework */,
100140
85E18DF7163D11C3001DFF48 /* SenTestingKit.framework */,
101141
85E18DD8163D11C3001DFF48 /* Other Frameworks */,
@@ -116,6 +156,25 @@
116156
85E18DDC163D11C3001DFF48 /* SynthDemo */ = {
117157
isa = PBXGroup;
118158
children = (
159+
85E18E36163D161B001DFF48 /* PlayerController.h */,
160+
85E18E37163D161B001DFF48 /* PlayerController.m */,
161+
85E18E16163D13AF001DFF48 /* ADSR.h */,
162+
85E18E17163D13AF001DFF48 /* ADSR.m */,
163+
85E18E18163D13AF001DFF48 /* BiquadFilter.h */,
164+
85E18E19163D13AF001DFF48 /* BiquadFilter.m */,
165+
85E18E1A163D13AF001DFF48 /* Generator.h */,
166+
85E18E1B163D13AF001DFF48 /* Oscillator.h */,
167+
85E18E1C163D13AF001DFF48 /* Oscillator.m */,
168+
85E18E1D163D13AF001DFF48 /* Player.h */,
169+
85E18E1E163D13AF001DFF48 /* Player.m */,
170+
85E18E1F163D13AF001DFF48 /* SawtoothGenerator.h */,
171+
85E18E20163D13AF001DFF48 /* SawtoothGenerator.m */,
172+
85E18E21163D13AF001DFF48 /* SineGenerator.h */,
173+
85E18E22163D13AF001DFF48 /* SineGenerator.m */,
174+
85E18E23163D13AF001DFF48 /* SquareGenerator.h */,
175+
85E18E24163D13AF001DFF48 /* SquareGenerator.m */,
176+
85E18E25163D13AF001DFF48 /* WhitenoiseGenerator.h */,
177+
85E18E26163D13AF001DFF48 /* WhitenoiseGenerator.m */,
119178
85E18DE8163D11C3001DFF48 /* AppDelegate.h */,
120179
85E18DE9163D11C3001DFF48 /* AppDelegate.m */,
121180
85E18DEB163D11C3001DFF48 /* MainMenu.xib */,
@@ -267,6 +326,15 @@
267326
85E18DE3163D11C3001DFF48 /* main.m in Sources */,
268327
85E18DEA163D11C3001DFF48 /* AppDelegate.m in Sources */,
269328
85E18DF0163D11C3001DFF48 /* SynthDemo.xcdatamodeld in Sources */,
329+
85E18E27163D13AF001DFF48 /* ADSR.m in Sources */,
330+
85E18E28163D13AF001DFF48 /* BiquadFilter.m in Sources */,
331+
85E18E29163D13AF001DFF48 /* Oscillator.m in Sources */,
332+
85E18E2A163D13AF001DFF48 /* Player.m in Sources */,
333+
85E18E2B163D13AF001DFF48 /* SawtoothGenerator.m in Sources */,
334+
85E18E2C163D13AF001DFF48 /* SineGenerator.m in Sources */,
335+
85E18E2D163D13AF001DFF48 /* SquareGenerator.m in Sources */,
336+
85E18E2E163D13AF001DFF48 /* WhitenoiseGenerator.m in Sources */,
337+
85E18E38163D161B001DFF48 /* PlayerController.m in Sources */,
270338
);
271339
runOnlyForDeploymentPostprocessing = 0;
272340
};

‎SynthDemo/ADSR.h

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// ADSR.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/26.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
#define SPEED 0.1f;
12+
13+
@interface ADSR : NSObject{
14+
float attack_time, attack_level, decay_time, decay_level,
15+
sustain_time, sustain_level, release_time, release_level;
16+
17+
float time;
18+
bool bFinish;
19+
}
20+
21+
@property(readwrite) float attack_time;
22+
@property(readwrite) float attack_level;
23+
@property(readwrite) float decay_time;
24+
@property(readwrite) float decay_level;
25+
@property(readwrite) float sustain_time;
26+
@property(readwrite) float sustain_level;
27+
@property(readwrite) float release_time;
28+
@property(readwrite) float release_level;
29+
@property(readwrite) float time;
30+
@property(readwrite) bool bFinish;
31+
32+
-(id)init;
33+
-(float)get; // 0.0 ~ 1.0の間
34+
-(void)noteOff;
35+
-(float)getValueOnLineX:(int)_x Y1:(int)_y1 Y2:(int)_y2 len:(int)_len;
36+
37+
@end

‎SynthDemo/ADSR.m

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//
2+
// ADSR.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/26.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "ADSR.h"
10+
11+
@implementation ADSR
12+
13+
@synthesize attack_time, attack_level, decay_time, decay_level, sustain_time, sustain_level, release_time, release_level, time, bFinish;
14+
15+
- (id) init
16+
{
17+
if (self = [super init])
18+
{
19+
NSLog(@"ADSR init");
20+
attack_time = 44100.0f;
21+
attack_level = 0.0f;
22+
decay_time = 44100.0f;
23+
decay_level = 1.0f;
24+
sustain_time = 44100.0f;
25+
sustain_level = 0.7f;
26+
release_time = 44100.0f;
27+
release_level = 0.5f;
28+
29+
time = 0;
30+
bFinish = NO;
31+
}
32+
33+
return self;
34+
}
35+
36+
-(float)get{
37+
time+=0.1f;
38+
int t = attack_time + decay_time + sustain_time+release_time;
39+
if(time > t){
40+
bFinish = YES;
41+
return 0.0f;
42+
}
43+
t -= release_time;
44+
if(time > t)
45+
return [self getValueOnLineX:time-t Y1:release_level Y2:0.0f len:release_time];
46+
47+
t -= sustain_time;
48+
if(time > t)
49+
return [self getValueOnLineX:time-t Y1:sustain_level Y2:release_level len:sustain_time];
50+
51+
t -= decay_time;
52+
if(time > t)
53+
return [self getValueOnLineX:time-t Y1:decay_level Y2:sustain_level len:decay_time];
54+
55+
return [self getValueOnLineX:time Y1:attack_level Y2:decay_level len:attack_time];
56+
57+
}
58+
59+
-(void)noteOff{
60+
release_level = [self get];
61+
time = attack_time + decay_time + sustain_time;
62+
}
63+
64+
-(float)getValueOnLineX:(int)_x Y1:(int)_y1 Y2:(int)_y2 len:(int)_len{
65+
return (_y2-_y1) * (_x-_len) / _len + _y1;
66+
}
67+
@end

‎SynthDemo/BiquadFilter.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// BiquadFilter.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "math.h"
11+
12+
#define SAMPLING_FREQ 44100.0f
13+
14+
@interface BiquadFilter : NSObject{
15+
float a0, a1, a2, b0, b1, b2;
16+
float x1, x2, y1, y2; // x1 = x[n-1], x2 = x[n-2], y1 = y[n-1], y2 = y[n-2]
17+
}
18+
19+
- (float) get:(float)_x;
20+
- (void) setLPF_f0:(float)_f0 Q:(float)_Q;
21+
- (void) setHPF_f0:(float)_f0 Q:(float)_Q;
22+
- (void) setBPF_f0:(float)_f0 Q:(float)_Q;
23+
- (void) setpeakingEQ_f0:(float)_f0 Q:(float)_Q dBGain:(float)_dBGain;
24+
- (void) setlowShelf_f0:(float)_f0 Q:(float)_Q dBGain:(float)_dBGain;
25+
- (void) sethighShelf_f0:(float)_f0 Q:(float)_Q dBGain:(float)_dBGain;
26+
27+
@end

‎SynthDemo/BiquadFilter.m

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
//
2+
// BiquadFilter.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "BiquadFilter.h"
10+
11+
@implementation BiquadFilter
12+
13+
- (float) get:(float)_x{
14+
float ret = (b0/a0)*_x + (b1/a0)*x1 + (b2/a0)*x2 - (a1/a0)*y1 - (a2/a0)*y2;
15+
x2 = x1;
16+
x1 = _x;
17+
y2 = y1;
18+
y1 = ret;
19+
return ret;
20+
}
21+
22+
- (void) setLPF_f0:(float)_f0 Q:(float)_Q{
23+
float w0 = 2*M_PI*_f0/SAMPLING_FREQ;
24+
float alpha = sin(w0)/(2*_Q);
25+
26+
b0 = (1 - cos(w0))/2;
27+
b1 = 1 - cos(w0);
28+
b2 = (1 - cos(w0))/2;
29+
a0 = 1 + alpha;
30+
a1 = -2*cos(w0);
31+
a2 = 1 - alpha;
32+
}
33+
34+
- (void) setHPF_f0:(float)_f0 Q:(float)_Q{
35+
float w0 = 2*M_PI*_f0/SAMPLING_FREQ;
36+
float alpha = sin(w0)/(2*_Q);
37+
38+
b0 = (1 + cos(w0))/2;
39+
b1 = -(1 + cos(w0));
40+
b2 = (1 + cos(w0))/2;
41+
a0 = 1 + alpha;
42+
a1 = -2*cos(w0);
43+
a2 = 1 - alpha;
44+
}
45+
46+
- (void) setBPF_f0:(float)_f0 Q:(float)_Q{
47+
float w0 = 2*M_PI*_f0/SAMPLING_FREQ;
48+
float alpha = sin(w0)/(2*_Q);
49+
50+
b0 = alpha;
51+
b1 = 0;
52+
b2 = -alpha;
53+
a0 = 1 + alpha;
54+
a1 = -2*cos(w0);
55+
a2 = 1 - alpha;
56+
}
57+
58+
59+
60+
61+
- (void) setpeakingEQ_f0:(float)_f0 Q:(float)_Q dBGain:(float)_dBGain{
62+
float w0 = 2*M_PI*_f0/SAMPLING_FREQ;
63+
float alpha = sin(w0)/(2*_Q);
64+
float A = pow(10, _dBGain/40);
65+
66+
b0 = 1 + alpha*A;
67+
b1 = -2*cos(w0);
68+
b2 = 1 - alpha*A;
69+
a0 = 1 + alpha/A;
70+
a1 = -2*cos(w0);
71+
a2 = 1 - alpha/A;
72+
}
73+
74+
- (void) setlowShelf_f0:(float)_f0 Q:(float)_Q dBGain:(float)_dBGain{
75+
float w0 = 2*M_PI*_f0/SAMPLING_FREQ;
76+
float alpha = sin(w0)/(2*_Q);
77+
float A = pow(10, _dBGain/40);
78+
79+
b0 = A*( (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha );
80+
b1 = 2*A*( (A-1) - (A+1)*cos(w0) );
81+
b2 = A*( (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha );
82+
a0 = (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha;
83+
a1 = -2*( (A-1) + (A+1)*cos(w0) );
84+
a2 = (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha;
85+
}
86+
87+
88+
- (void) sethighShelf_f0:(float)_f0 Q:(float)_Q dBGain:(float)_dBGain{
89+
float w0 = 2*M_PI*_f0/SAMPLING_FREQ;
90+
float alpha = sin(w0)/(2*_Q);
91+
float A = pow(10, _dBGain/40);
92+
93+
b0 = A*( (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha );
94+
b1 = -2*A*( (A-1) + (A+1)*cos(w0) );
95+
b2 = A*( (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha );
96+
a0 = (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha;
97+
a1 = 2*( (A-1) - (A+1)*cos(w0) );
98+
a2 = (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha;
99+
}
100+
@end

‎SynthDemo/Generator.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Generator.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/27.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@protocol Generator <NSObject>
12+
-(float) get; // -1.0 ~ 1.0の間で返す
13+
-(void) setFreq:(float)_freq;
14+
@end

‎SynthDemo/Oscillator.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// Oscillator.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/27.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Generator.h"
11+
#import "BiquadFilter.h"
12+
#import "ADSR.h"
13+
14+
@interface Oscillator : NSObject{
15+
id<Generator> gen;
16+
ADSR *ampADSR;
17+
float velocity;
18+
BiquadFilter *filter;
19+
}
20+
21+
-(id)initWithGen:(id<Generator>)_gen ADSR:_ampADSR Filter:_filter;
22+
-(void)dealloc;
23+
-(float)get; // -1.0fから1.0fの間で返す
24+
-(void)setFreq:(float)_value;
25+
- (void)changeOscillator:(id<Generator>)_gen;
26+
27+
@end

‎SynthDemo/Oscillator.m

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// Oscillator.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/27.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "Oscillator.h"
10+
11+
@implementation Oscillator
12+
13+
- (id) initWithGen:(id<Generator>)_gen ADSR:_ampADSR Filter:_filter
14+
{
15+
if (self = [super init])
16+
{
17+
NSLog(@"Oscillator init");
18+
gen = _gen;
19+
ampADSR = _ampADSR;
20+
filter = _filter;
21+
velocity = 1.0f;
22+
}
23+
24+
return self;
25+
}
26+
27+
- (void)dealloc
28+
{
29+
/*
30+
[gen release];
31+
[ampADSR dealloc];
32+
[filter dealloc];
33+
[super dealloc];
34+
*/
35+
}
36+
37+
- (float)get
38+
{
39+
float outputValue = [gen get]; // * [ampADSR get];
40+
outputValue = [filter get:outputValue];
41+
outputValue *= velocity;
42+
43+
return outputValue;
44+
}
45+
46+
-(void)setFreq:(float)_value
47+
{
48+
[gen setFreq:_value];
49+
}
50+
51+
// ジェネレータの変更
52+
- (void)changeOscillator:(id<Generator>)_gen
53+
{
54+
//[gen release];
55+
gen = _gen;
56+
57+
}
58+
59+
@end

‎SynthDemo/Player.h

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// Player.h
3+
// wpak32pre1
4+
//
5+
// Created by 圭太 宮崎 on 12/07/08.
6+
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
//#import <AudioToolbox/ExtendedAudioFile.h>
11+
#import <AudioToolbox/AudioQueue.h>
12+
13+
#import "Oscillator.h"
14+
#import "Generator.h"
15+
#import "SineGenerator.h"
16+
#import "SawtoothGenerator.h"
17+
#import "WhitenoiseGenerator.h"
18+
#import "BiquadFilter.h"
19+
20+
#define CHANNEL_NUM 2
21+
#define BITS sizeof(float) * 8 //32 // floatは4bytes = 32bits
22+
23+
#define NUM_BUFFERS 3
24+
25+
typedef struct AQCallbackStruct {
26+
AudioQueueRef queue;
27+
UInt32 frameCount;
28+
AudioQueueBufferRef mBuffers[NUM_BUFFERS];
29+
AudioStreamBasicDescription mDataFormat;
30+
} AQCallbackStruct;
31+
AQCallbackStruct in;
32+
33+
@interface Player : NSObject{
34+
AudioQueueRef queue;
35+
Float64 mSamplingRate;
36+
BOOL mPlaying; // 再生中フラグ
37+
id mDelegate; // delegate
38+
39+
float volume;
40+
Oscillator *osc;
41+
ADSR *ampADSR;
42+
BiquadFilter *filter;
43+
}
44+
45+
@property(readwrite) BOOL mPlaying;
46+
@property(readwrite) float volume;
47+
@property(retain) id osc;
48+
@property(retain) BiquadFilter *filter;
49+
50+
- (id)init:(id)delegate;
51+
- (void)dealloc;
52+
- (BOOL)initAU;
53+
- (id)delegate;
54+
- (void)play;
55+
- (void)pause;
56+
- (void)changeOscillator:(id<Generator>)_osc;
57+
58+
@end
59+
60+
Player *player;

‎SynthDemo/Player.m

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
//
2+
// Player.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/24.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "Player.h"
10+
11+
@implementation Player
12+
@synthesize volume, mPlaying, osc, filter;
13+
14+
15+
static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) {
16+
int i;
17+
OSStatus err;
18+
int outputValue;
19+
20+
AQCallbackStruct *inData = (AQCallbackStruct *)in;
21+
short *coreAudioBuffer = (short*) outQB->mAudioData;
22+
23+
24+
if (inData->frameCount > 0) {
25+
outQB->mAudioDataByteSize = 4*inData->frameCount;
26+
27+
for(i=0; i<inData->frameCount*2; i=i+2) {
28+
if(player.mPlaying){
29+
outputValue = [player.osc get] * 32767.0f;
30+
// outputValue = [player->filter get:outputValue];
31+
32+
// guard
33+
if(outputValue > 32767) outputValue = 32767;
34+
else if(outputValue < -32768) outputValue = -32768;
35+
36+
// volume
37+
outputValue *= player.volume;
38+
39+
// output
40+
coreAudioBuffer[i] = outputValue;
41+
coreAudioBuffer[i+1] = coreAudioBuffer[i];
42+
} else {
43+
coreAudioBuffer[i] = 0;
44+
coreAudioBuffer[i+1] = 0;
45+
}
46+
}
47+
AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL);
48+
} else {
49+
err = AudioQueueStop(inData->queue, false);
50+
}
51+
}
52+
53+
// 初期化メソッド
54+
- (id)init:(id)delegate
55+
{
56+
self = [super init];
57+
if( self==nil )
58+
return nil;
59+
player = self;
60+
61+
// initialize メンバ変数
62+
NSLog(@"Player init initialize value");
63+
64+
filter = [[BiquadFilter alloc] init];
65+
[filter setLPF_f0:600.0f Q:1.0f];
66+
67+
ampADSR = [[ADSR alloc] init];
68+
69+
osc = [[Oscillator alloc] initWithGen:[[SineGenerator alloc] init] ADSR:ampADSR Filter:filter];
70+
71+
mDelegate = delegate;
72+
mPlaying = NO;
73+
volume = 0.8f;
74+
75+
// AudioUnitの初期化
76+
NSLog(@"Player Audiounit initialize");
77+
bool bRet = [self initAU];
78+
if(bRet != YES){
79+
//[self release];
80+
return nil;
81+
}
82+
83+
84+
return self;
85+
}
86+
87+
// AudioUnitの初期化
88+
- (BOOL)initAU
89+
{
90+
OSStatus err;
91+
92+
// config AQCallBack
93+
in.mDataFormat.mSampleRate = 44100.0;
94+
in.mDataFormat.mFormatID = kAudioFormatLinearPCM;
95+
in.mDataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
96+
in.mDataFormat.mBytesPerPacket = 4;
97+
in.mDataFormat.mFramesPerPacket = 1;
98+
in.mDataFormat.mBytesPerFrame = 4;
99+
in.mDataFormat.mChannelsPerFrame = 2;
100+
in.mDataFormat.mBitsPerChannel = 16;
101+
in.frameCount = 1024;
102+
103+
err = AudioQueueNewOutput(&in.mDataFormat, AQBufferCallback, &in, CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &in.queue);
104+
if(err) NSLog(@"AudioQueueNewOutput err %d", err);
105+
106+
UInt32 bufferBytes = in.frameCount * in.mDataFormat.mBytesPerFrame;
107+
108+
for (int i=0; i< NUM_BUFFERS; i++) {
109+
err = AudioQueueAllocateBuffer(in.queue, bufferBytes, &in.mBuffers[i]);
110+
if(err) NSLog(@"AudioQueueAllocateBuffer [%d] err %d",i, err);
111+
AQBufferCallback (&in, in.queue, in.mBuffers[i]);
112+
}
113+
114+
err = AudioQueueSetParameter(in.queue, kAudioQueueParam_Volume, 1.0);
115+
if(err) NSLog(@"AudioQueueSetParameter err %d", err);
116+
117+
err = AudioQueueStart(in.queue, NULL);
118+
if(err) NSLog(@"AudioQueueStart err %d", err);
119+
120+
queue = in.queue;
121+
122+
NSLog(@"initAU %d\n", YES);
123+
124+
return YES;
125+
126+
}
127+
128+
// リリース
129+
- (void)dealloc
130+
{
131+
AudioQueueStop(queue,true);
132+
AudioQueueDispose(queue, true);
133+
134+
/*
135+
[ampADSR dealloc];
136+
[filter dealloc];
137+
[osc release];
138+
[super dealloc];
139+
*/
140+
}
141+
142+
143+
144+
// delegateオブジェクトの取得
145+
- (id)delegate
146+
{
147+
return mDelegate;
148+
}
149+
150+
// 再生開始
151+
- (void)play
152+
{
153+
mPlaying = YES;
154+
NSLog(@"mPlaying: %d\n", mPlaying);
155+
}
156+
157+
// 一時停止
158+
- (void)pause
159+
{
160+
mPlaying = NO;
161+
NSLog(@"mPlaying: %d\n", mPlaying);
162+
}
163+
164+
// オシレータの変更
165+
- (void)changeOscillator:(id<Generator>)_gen
166+
{
167+
bool b = mPlaying;
168+
if(b) mPlaying = NO;
169+
170+
[osc changeOscillator:_gen];
171+
172+
if(b) mPlaying = YES;
173+
}
174+
175+
176+
@end

‎SynthDemo/PlayerController.h

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//
2+
// PlayerContoroller.h
3+
// SynthDemo
4+
//
5+
// Created by Keita Miyazaki on 12/10/28.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
10+
#import <Foundation/Foundation.h>
11+
#import <CoreMIDI/CoreMIDI.h>
12+
#import "Player.h"
13+
#import "Generator.h"
14+
#import "SineGenerator.h"
15+
#import "SawtoothGenerator.h"
16+
#import "SquareGenerator.h"
17+
#import "WhitenoiseGenerator.h"
18+
19+
20+
@class Player;
21+
22+
#define CHANNEL_NUM 2
23+
24+
@interface PlayerController : NSObject{
25+
Player* player;
26+
IBOutlet NSButton *playButton;
27+
IBOutlet NSSlider *volumeSlider;
28+
29+
IBOutlet NSMatrix *ganeratorRadioGroup;
30+
31+
IBOutlet NSSlider *frequencySlider;
32+
33+
IBOutlet NSMatrix *filterRadioGroup;
34+
IBOutlet NSSlider *filterFrequencySlider;
35+
IBOutlet NSSlider *filterQSlider;
36+
IBOutlet NSSlider *filterdBGainSlider;
37+
}
38+
39+
-(id) init;
40+
-(void)dealloc;
41+
-(IBAction)play:(id)sender;
42+
-(IBAction)setOscillator:(id)sender;
43+
-(IBAction)setFilter:(id)sender;
44+
-(IBAction)setFrequency:(id)sender;
45+
-(IBAction)setVolume:(id)sender;
46+
47+
- (double)getFreqWithMIDI:(int)_note;
48+
49+
@end
50+
51+
PlayerController *playerController;

‎SynthDemo/PlayerController.m

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
//
2+
// PlayerContoroller.m
3+
// SynthDemo
4+
//
5+
// Created by Keita Miyazaki on 12/10/28.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "PlayerController.h"
10+
11+
static void
12+
MIDIInputProc(const MIDIPacketList *pktlist,
13+
void *readProcRefCon, void *srcConnRefCon)
14+
{
15+
//MIDIパケットリストの先頭のMIDIPacketのポインタを取得
16+
MIDIPacket *packet = (MIDIPacket *)&(pktlist->packet[0]);
17+
//パケットリストからパケットの数を取得
18+
UInt32 packetCount = pktlist->numPackets;
19+
20+
for (NSInteger i = 0; i < packetCount; i++) {
21+
22+
//data[0]からメッセージの種類とチャンネルを分けて取得する
23+
Byte mes = packet->data[0] & 0xF0;
24+
Byte ch = packet->data[0] & 0x0F;
25+
26+
//メッセージの種類に応じてログに表示
27+
if ((mes == 0x90) && (packet->data[2] != 0)) {
28+
float freq = [playerController getFreqWithMIDI:packet->data[1]];
29+
NSLog(@"note on number = %2.2x(%f) / velocity = %2.2x / channel = %2.2x",
30+
packet->data[1], freq, packet->data[2], ch);
31+
//@[player.osc setFreq:freq];
32+
} else if (mes == 0x80 || mes == 0x90) {
33+
NSLog(@"note off number = %2.2x / velocity = %2.2x / channel = %2.2x",
34+
packet->data[1], packet->data[2], ch);
35+
} else if (mes == 0xB0) {
36+
NSLog(@"cc number = %2.2x / data = %2.2x / channel = %2.2x",
37+
packet->data[1], packet->data[2], ch);
38+
} /*else {
39+
NSLog(@"etc");
40+
}*/
41+
42+
//次のパケットへ進む
43+
packet = MIDIPacketNext(packet);
44+
}
45+
}
46+
47+
48+
@implementation PlayerController
49+
50+
- (id) init
51+
{
52+
if (self = [super init])
53+
{
54+
NSLog(@"init");
55+
player = [[Player alloc] init:self];
56+
57+
// midi inputの初期化
58+
OSStatus err;
59+
NSString *clientName;
60+
MIDIClientRef inputClientRef;
61+
MIDIPortRef inputPortRef;
62+
63+
clientName = @"inputClient";
64+
err = MIDIClientCreate((__bridge CFStringRef)clientName, NULL, NULL, &inputClientRef);
65+
if (err != noErr) {
66+
NSLog(@"MIDIClientCreate err = %d", err);
67+
} else{
68+
//MIDIポートを作成する
69+
NSString *inputPortName = @"inputPort";
70+
err = MIDIInputPortCreate(
71+
inputClientRef, (__bridge CFStringRef)inputPortName,
72+
MIDIInputProc, NULL, &inputPortRef);
73+
if (err != noErr) {
74+
NSLog(@"MIDIInputPortCreate err = %d", err);
75+
} else {
76+
//MIDIエンドポイントを取得し、MIDIポートに接続する
77+
ItemCount sourceCount = MIDIGetNumberOfSources();
78+
for (ItemCount i = 0; i < sourceCount; i++) {
79+
MIDIEndpointRef sourcePointRef = MIDIGetSource(i);
80+
err = MIDIPortConnectSource(inputPortRef, sourcePointRef, NULL);
81+
if (err != noErr) {
82+
NSLog(@"MIDIPortConnectSource err = %d", err);
83+
}
84+
}
85+
}
86+
87+
}
88+
89+
playerController = self;
90+
}
91+
92+
return self;
93+
}
94+
95+
- (void)dealloc
96+
{
97+
NSLog(@"PlayerController dealloc");
98+
//[player dealloc];
99+
//[super dealloc];
100+
}
101+
102+
- (IBAction)play:(id)sender{
103+
if(player.mPlaying){
104+
[player pause];
105+
playButton.title = @"Play";
106+
} else {
107+
[player play];
108+
playButton.title = @"Pause";
109+
}
110+
}
111+
112+
- (IBAction)setOscillator:(id)sender{
113+
NSLog(@"setOscillator:%ld, %@\n", ganeratorRadioGroup.selectedRow, [[ganeratorRadioGroup selectedCell] title]);
114+
115+
id<Generator> osc;
116+
switch(ganeratorRadioGroup.selectedRow){
117+
case 1:
118+
osc = [[SawtoothGenerator alloc] init];
119+
break;
120+
case 2:
121+
osc = [[SquareGenerator alloc] init];
122+
break;
123+
case 3:
124+
osc = [[WhitenoiseGenerator alloc] init];
125+
break;
126+
default:
127+
osc = [[SineGenerator alloc] init];
128+
break;
129+
}
130+
131+
[player changeOscillator:osc];
132+
}
133+
134+
- (IBAction)setFilter:(id)sender{
135+
switch(filterRadioGroup.selectedRow){
136+
case 0:
137+
[player.filter setLPF_f0:filterFrequencySlider.floatValue Q:filterQSlider.floatValue];
138+
break;
139+
case 1:
140+
[player.filter setHPF_f0:filterFrequencySlider.floatValue Q:filterQSlider.floatValue];
141+
break;
142+
case 2:
143+
[player.filter setBPF_f0:filterFrequencySlider.floatValue Q:filterQSlider.floatValue];
144+
break;
145+
case 3:
146+
[player.filter setpeakingEQ_f0:filterFrequencySlider.floatValue Q:filterQSlider.floatValue dBGain:filterdBGainSlider.floatValue];
147+
break;
148+
case 4:
149+
[player.filter setlowShelf_f0:filterFrequencySlider.floatValue Q:filterQSlider.floatValue dBGain:filterdBGainSlider.floatValue];
150+
break;
151+
case 5:
152+
[player.filter sethighShelf_f0:filterFrequencySlider.floatValue Q:filterQSlider.floatValue dBGain:filterdBGainSlider.floatValue];
153+
break;
154+
}
155+
}
156+
157+
-(IBAction)setFrequency:(id)sender{
158+
[player.osc setFreq:frequencySlider.floatValue];
159+
}
160+
161+
-(IBAction)setVolume:(id)sender{
162+
[player setVolume:volumeSlider.floatValue/100.0f];
163+
}
164+
165+
// midiノート番号から周波数を求める
166+
-(double)getFreqWithMIDI:(int)_note{
167+
// A(69) = 440hzを利用
168+
return 440.0f * pow(2.0f, (_note-69) / 12.0f);
169+
}
170+
171+
@end

‎SynthDemo/SawtoothGenerator.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// SawtoothOscillator.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Generator.h"
11+
12+
@interface SawtoothGenerator : NSObject<Generator>{
13+
float radius;
14+
float frequency;
15+
}
16+
-(id) init;
17+
-(float) get;
18+
-(void) setFreq:(float)_freq;
19+
@end

‎SynthDemo/SawtoothGenerator.m

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// SawtoothOscillator.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "SawtoothGenerator.h"
10+
11+
@implementation SawtoothGenerator
12+
13+
- (id) init
14+
{
15+
if (self = [super init])
16+
{
17+
NSLog(@"SawtoothGenerator init");
18+
radius = 0;
19+
frequency = 440;
20+
}
21+
22+
return self;
23+
}
24+
25+
-(float) get{
26+
radius += (2.0 * M_PI * frequency) / 44100.0;
27+
if(radius >= M_PI*2) radius -= M_PI*2;
28+
return radius / M_PI - 1.0f;
29+
}
30+
31+
-(void) setFreq:(float)_freq{
32+
frequency = _freq;
33+
}
34+
35+
@end

‎SynthDemo/SineGenerator.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// SineOscillator.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Generator.h"
11+
12+
@interface SineGenerator : NSObject<Generator>{
13+
float radius;
14+
float frequency;
15+
}
16+
-(id) init;
17+
-(float) get;
18+
-(void) setFreq:(float)_freq;
19+
@end

‎SynthDemo/SineGenerator.m

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// SineOscillator.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "SineGenerator.h"
10+
11+
@implementation SineGenerator
12+
13+
- (id) init
14+
{
15+
if (self = [super init])
16+
{
17+
NSLog(@"SineGenerator init");
18+
radius = 0;
19+
frequency = 440;
20+
}
21+
22+
return self;
23+
}
24+
25+
-(float) get{
26+
radius += (2.0 * M_PI * frequency) / 44100.0;
27+
if(radius >= M_PI*2) radius -= M_PI*2;
28+
return sin(radius);
29+
}
30+
31+
-(void) setFreq:(float)_freq{
32+
frequency = _freq;
33+
}
34+
35+
@end

‎SynthDemo/SquareGenerator.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// SquareOscillator.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Generator.h"
11+
12+
@interface SquareGenerator : NSObject<Generator>{
13+
float radius;
14+
float frequency;
15+
}
16+
-(id) init;
17+
-(float) get;
18+
-(void) setFreq:(float)_freq;
19+
@end

‎SynthDemo/SquareGenerator.m

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// SquareOscillator.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "SquareGenerator.h"
10+
11+
@implementation SquareGenerator
12+
13+
- (id) init
14+
{
15+
if (self = [super init])
16+
{
17+
NSLog(@"SawtoothGenerator init");
18+
radius = 0;
19+
frequency = 440;
20+
}
21+
22+
return self;
23+
}
24+
25+
-(float) get{
26+
radius += (2.0 * M_PI * frequency) / 44100.0;
27+
if(radius >= M_PI*2) radius -= M_PI*2;
28+
return radius > M_PI ? 1.0f : -1.0f;
29+
}
30+
31+
-(void) setFreq:(float)_freq{
32+
frequency = _freq;
33+
}
34+
35+
@end

‎SynthDemo/WhitenoiseGenerator.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// WhitenoiseOscillator.h
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Generator.h"
11+
12+
@interface WhitenoiseGenerator : NSObject<Generator>{
13+
14+
}
15+
-(id) init;
16+
-(float) get;
17+
-(void) setFreq:(float)_freq;
18+
@end

‎SynthDemo/WhitenoiseGenerator.m

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// WhitenoiseOscillator.m
3+
// SynthTest
4+
//
5+
// Created by Keita Miyazaki on 12/10/25.
6+
// Copyright (c) 2012年 Keita Miyazaki. All rights reserved.
7+
//
8+
9+
#import "WhitenoiseGenerator.h"
10+
11+
@implementation WhitenoiseGenerator
12+
13+
- (id) init
14+
{
15+
if (self = [super init])
16+
{
17+
NSLog(@"WhitenoiseGeneratorr init");
18+
}
19+
20+
return self;
21+
}
22+
23+
-(float) get{
24+
return (float) random()/RAND_MAX;
25+
}
26+
27+
-(void) setFreq:(float)_freq{
28+
NSLog(@"Whitenoise dont's use freq=%f parameter.", _freq);
29+
}
30+
31+
@end

‎SynthDemo/en.lproj/MainMenu.xib

+2,017-1,565
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.