Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AudioSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ typedef struct {
- (MusicDeviceInstrumentID)currentInstrumentOnChannel:(int)channel;
- (void)setInstrument:(MusicDeviceInstrumentID)instrumentID forChannel:(int)channel;

- (float)getVolume;
- (void)setVolume:(float)value;

- (float)getFilterCutoffMin;
- (float)getFilterCutoffMax;
- (float)getFilterCutoff;
Expand Down
38 changes: 31 additions & 7 deletions AudioSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,25 @@ - (void)setUpAudio;
// This takes the file and attempts to load it into the synth unit
- (BOOL)openFile:(NSString*)filename
{
FSSpec fsSpec;
AudioUnit synthUnit;
OSStatus error;
int i;

if (![filename makeFSSpec:&fsSpec]) return NO;

NSURL *fileURL;

fileURL = [NSURL fileURLWithPath:filename];

if (!fileURL) return NO;

AUGraphStop(graph);

AUGraphGetNodeInfo (graph, synthNode, NULL, NULL, NULL, &synthUnit);
error = AudioUnitSetProperty (
synthUnit,
kMusicDeviceProperty_SoundBankFSSpec, kAudioUnitScope_Global,
kMusicDeviceProperty_SoundBankURL, kAudioUnitScope_Global,
0,
&fsSpec, sizeof (fsSpec)
&fileURL, sizeof(fileURL)
);

AUGraphStart(graph);

if (error) return NO;
Expand Down Expand Up @@ -313,6 +315,28 @@ - (float)getFilterCutoffMax
return info.maxValue;
}

- (float)getVolume
{
AudioUnit volumeUnit;
float value;

AUGraphGetNodeInfo (graph, outputNode, NULL, NULL, NULL, &volumeUnit);

AudioUnitGetParameter (volumeUnit, kHALOutputParam_Volume, kAudioUnitScope_Output, 0, &value);

return value;
}

- (void)setVolume:(float)value
{
AudioUnit volumeUnit;

AUGraphGetNodeInfo (graph, outputNode, NULL, NULL, NULL, &volumeUnit);

AudioUnitSetParameter(volumeUnit, kHALOutputParam_Volume, kAudioUnitScope_Output, 0, value, 0);
}


- (float)getFilterCutoff
{
AudioUnit filterUnit;
Expand Down
79 changes: 0 additions & 79 deletions English.lproj/MainMenu.nib/classes.nib

This file was deleted.

549 changes: 549 additions & 0 deletions English.lproj/MainMenu.nib/designable.nib

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions English.lproj/MainMenu.nib/info.nib

This file was deleted.

Binary file modified English.lproj/MainMenu.nib/keyedobjects.nib
Binary file not shown.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundleIdentifier</key>
<string>com.notahat.SimpleSynth</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SimpleSynth - A MIDI synth for Mac

I added a volume control slider and updated the project to build for MacOS 10.13.4 High Sierra.

![38577945-715d8320-3cd0-11e8-801e-3fa0b0b9b03e.png](https://user-images.githubusercontent.com/28652/38577945-715d8320-3cd0-11e8-801e-3fa0b0b9b03e.png)
Loading