2006-10-24 07:15:46 +00:00
|
|
|
//
|
2007-04-27 06:41:34 +00:00
|
|
|
// File: VLPitchTransformer.mm - Bindings helper for MIDI pitch
|
2006-10-24 07:15:46 +00:00
|
|
|
//
|
2007-04-27 06:41:34 +00:00
|
|
|
// Author(s):
|
|
|
|
//
|
|
|
|
// (MN) Matthias Neeracher
|
|
|
|
//
|
2011-08-27 22:12:32 +00:00
|
|
|
// Copyright © 2006-2011 Matthias Neeracher
|
2006-10-24 07:15:46 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "VLPitchTransformer.h"
|
2011-08-27 22:12:32 +00:00
|
|
|
#import "VLPitchName.h"
|
2006-10-24 07:15:46 +00:00
|
|
|
|
|
|
|
@implementation VLPitchTransformer
|
|
|
|
|
|
|
|
+ (Class)transformedValueClass
|
|
|
|
{
|
|
|
|
return [NSString class];
|
|
|
|
}
|
|
|
|
|
|
|
|
const char * sPitch2Name = "C D EF G A B";
|
|
|
|
|
|
|
|
- (NSString *)transformedValue:(id)value
|
|
|
|
{
|
|
|
|
int pitch = [value intValue];
|
|
|
|
int octave= (pitch / 12)-1;
|
|
|
|
pitch %= 12;
|
|
|
|
if (sPitch2Name[pitch] == ' ')
|
|
|
|
return [NSString stringWithFormat:@"%c%C%d / %c%C%d",
|
2013-06-01 21:19:02 +00:00
|
|
|
sPitch2Name[pitch-1], unichar(kVLSharpChar), octave,
|
|
|
|
sPitch2Name[pitch+1], unichar(kVLFlatChar), octave];
|
2006-10-24 07:15:46 +00:00
|
|
|
else
|
|
|
|
return [NSString stringWithFormat:@"%c%d",
|
|
|
|
sPitch2Name[pitch], octave];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|