-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInstrument.m
53 lines (44 loc) · 1.32 KB
/
Instrument.m
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
//
// Instrument.m
// lovestep
//
// Created by Zachary Waleed Saraf on 12/3/13.
// Copyright (c) 2013 Zachary Waleed Saraf. All rights reserved.
//
#import "Instrument.h"
@implementation Instrument
-(id)initWithFluidSynthBank:(NSInteger)bank
program:(NSInteger)program
volumeRatio:(CGFloat)volumeRatio
name:(NSString *)name;
{
if (self = [super init]) {
self.program = program;
self.bank = bank;
self.volumeRatio = volumeRatio;
self.name = name;
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super init]) {
self.program = [aDecoder decodeIntegerForKey:@"program"];
self.bank = [aDecoder decodeIntegerForKey:@"bank"];
self.volumeRatio = [aDecoder decodeFloatForKey:@"volumeRatio"];
self.name = [aDecoder decodeObjectForKey:@"name"];
}
return self;
}
+(Instrument *)defaultInstrument
{
return [[Instrument alloc] initWithFluidSynthBank:0 program:1 volumeRatio:1 name:@"Grand Piano"];
}
-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.name forKey:@"name"];
[aCoder encodeInteger:self.program forKey:@"program"];
[aCoder encodeInteger:self.bank forKey:@"bank"];
[aCoder encodeFloat:self.volumeRatio forKey:@"volumeRatio"];
}
@end