mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 03:04:00 +00:00
Implement preferences, user pitch range
This commit is contained in:
parent
6886a2d9f9
commit
32ef9e2386
10
English.lproj/MainMenu.nib/classes.nib
generated
10
English.lproj/MainMenu.nib/classes.nib
generated
|
@ -1,4 +1,12 @@
|
|||
{
|
||||
IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; });
|
||||
IBClasses = (
|
||||
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||
{
|
||||
ACTIONS = {playNewPitch = id; };
|
||||
CLASS = VLAppController;
|
||||
LANGUAGE = ObjC;
|
||||
SUPERCLASS = NSObject;
|
||||
}
|
||||
);
|
||||
IBVersion = 1;
|
||||
}
|
1
English.lproj/MainMenu.nib/info.nib
generated
1
English.lproj/MainMenu.nib/info.nib
generated
|
@ -13,6 +13,7 @@
|
|||
<string>452.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>217</integer>
|
||||
<integer>29</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
|
|
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
10
Resources/UserDefaults.plist
Normal file
10
Resources/UserDefaults.plist
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>VLHighPitch</key>
|
||||
<integer>75</integer>
|
||||
<key>VLLowPitch</key>
|
||||
<integer>57</integer>
|
||||
</dict>
|
||||
</plist>
|
17
Sources/VLAppController.h
Normal file
17
Sources/VLAppController.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// VLAppController.h
|
||||
// Vocalese
|
||||
//
|
||||
// Created by Matthias Neeracher on 10/23/06.
|
||||
// Copyright 2006 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface VLAppController : NSObject {
|
||||
|
||||
}
|
||||
|
||||
- (IBAction) playNewPitch:(id)sender;
|
||||
|
||||
@end
|
63
Sources/VLAppController.mm
Normal file
63
Sources/VLAppController.mm
Normal file
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// VLAppController.mm
|
||||
// Vocalese
|
||||
//
|
||||
// Created by Matthias Neeracher on 10/23/06.
|
||||
// Copyright 2006 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "VLAppController.h"
|
||||
#import "VLPitchTransformer.h"
|
||||
#import "VLSoundOut.h"
|
||||
|
||||
@implementation VLAppController
|
||||
|
||||
+ (void)setupDefaults
|
||||
{
|
||||
// load the default values for the user defaults
|
||||
NSString * userDefaultsValuesPath =
|
||||
[[NSBundle mainBundle] pathForResource:@"UserDefaults" ofType:@"plist"];
|
||||
NSDictionary * userDefaultsValuesDict =
|
||||
[NSDictionary dictionaryWithContentsOfFile:userDefaultsValuesPath];
|
||||
|
||||
// set them in the standard user defaults
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
|
||||
|
||||
// if your application supports resetting a subset of the defaults to
|
||||
// factory values, you should set those values
|
||||
// in the shared user defaults controller
|
||||
NSArray * resettableUserDefaultsKeys =
|
||||
[NSArray arrayWithObjects:@"VLLowPitch",@"VLHighPitch",nil];
|
||||
NSDictionary * initialValuesDict =
|
||||
[userDefaultsValuesDict dictionaryWithValuesForKeys:resettableUserDefaultsKeys];
|
||||
|
||||
// Set the initial values in the shared user defaults controller
|
||||
[[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initialValuesDict];
|
||||
}
|
||||
|
||||
+ (void)setupTransformers
|
||||
{
|
||||
VLPitchTransformer * pitchTransformer;
|
||||
|
||||
// create an autoreleased instance of our value transformer
|
||||
pitchTransformer = [[[VLPitchTransformer alloc] init] autorelease];
|
||||
|
||||
// register it with the name that we refer to it with
|
||||
[NSValueTransformer setValueTransformer:pitchTransformer
|
||||
forName:@"VLPitchTransformer"];
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
[self setupDefaults];
|
||||
[self setupTransformers];
|
||||
}
|
||||
|
||||
- (IBAction) playNewPitch:(id)sender
|
||||
{
|
||||
VLNote note(VLFraction(1,4), [sender intValue]);
|
||||
|
||||
VLSoundOut::Instance()->PlayNote(note);
|
||||
}
|
||||
|
||||
@end
|
|
@ -84,9 +84,11 @@ static std::string PitchName(int8_t pitch, bool useSharps)
|
|||
if (kScale[pitch] != ' ')
|
||||
return static_cast<char>(std::toupper(kScale[pitch])) + std::string();
|
||||
else if (useSharps)
|
||||
return static_cast<char>(std::toupper(kScale[pitch-1])) + std::string("♯");
|
||||
return static_cast<char>(std::toupper(kScale[pitch-1]))
|
||||
+ std::string(kVLSharpStr);
|
||||
else
|
||||
return static_cast<char>(std::toupper(kScale[pitch+1])) + std::string("♭");
|
||||
return static_cast<char>(std::toupper(kScale[pitch+1]))
|
||||
+ std::string(kVLFlatStr);
|
||||
}
|
||||
|
||||
static std::string LilypondPitchName(int8_t pitch, bool useSharps)
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
#include <string>
|
||||
#include <inttypes.h>
|
||||
|
||||
const int kVLSharpChar = 0x266F;
|
||||
const int kVLFlatChar = 0x266D;
|
||||
const char *kVLSharpStr = "\xE2\x99\xAF";
|
||||
const char *kVLFlatStr = "\xE2\x99\xAD";
|
||||
|
||||
struct VLFract {
|
||||
uint16_t fNum; // Numerator
|
||||
uint16_t fDenom; // Denominator
|
||||
|
|
18
Sources/VLPitchTransformer.h
Normal file
18
Sources/VLPitchTransformer.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// VLPitchTransformer.h
|
||||
// Vocalese
|
||||
//
|
||||
// Created by Matthias Neeracher on 10/23/06.
|
||||
// Copyright 2006 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface VLPitchTransformer : NSValueTransformer {
|
||||
}
|
||||
|
||||
+ (Class)transformedValueClass;
|
||||
|
||||
- (NSString *)transformedValue:(id)value;
|
||||
|
||||
@end
|
35
Sources/VLPitchTransformer.mm
Normal file
35
Sources/VLPitchTransformer.mm
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// VLPitchTransformer.mm
|
||||
// Vocalese
|
||||
//
|
||||
// Created by Matthias Neeracher on 10/23/06.
|
||||
// Copyright 2006 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "VLPitchTransformer.h"
|
||||
#import "VLModel.h"
|
||||
|
||||
@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",
|
||||
sPitch2Name[pitch-1], kVLSharpChar, octave,
|
||||
sPitch2Name[pitch+1], kVLFlatChar, octave];
|
||||
else
|
||||
return [NSString stringWithFormat:@"%c%d",
|
||||
sPitch2Name[pitch], octave];
|
||||
}
|
||||
|
||||
@end
|
|
@ -23,6 +23,8 @@
|
|||
952DCD78096BBB11001C2316 /* VLSheetViewChords.mm in Sources */ = {isa = PBXBuildFile; fileRef = 952DCD77096BBB11001C2316 /* VLSheetViewChords.mm */; };
|
||||
953722670AE9F0E100B6E483 /* VLLilypondDocument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 953722660AE9F0E100B6E483 /* VLLilypondDocument.mm */; };
|
||||
95498DBD0AE3812F006B5F81 /* VLSoundSched.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95498DBC0AE3812F006B5F81 /* VLSoundSched.mm */; };
|
||||
954BBD860AEDDE5300BBFD5F /* VLAppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 954BBD850AEDDE5300BBFD5F /* VLAppController.mm */; };
|
||||
954BBD9A0AEDE81500BBFD5F /* VLPitchTransformer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 954BBD990AEDE81500BBFD5F /* VLPitchTransformer.mm */; };
|
||||
955E58E5095658AB0045FDA5 /* VLModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955E58E4095658AB0045FDA5 /* VLModel.cpp */; };
|
||||
955E59610957C1400045FDA5 /* TVLChord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955E59600957C1400045FDA5 /* TVLChord.cpp */; };
|
||||
955E59640957C15A0045FDA5 /* VLModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955E58E4095658AB0045FDA5 /* VLModel.cpp */; };
|
||||
|
@ -73,6 +75,10 @@
|
|||
953722660AE9F0E100B6E483 /* VLLilypondDocument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = VLLilypondDocument.mm; path = Sources/VLLilypondDocument.mm; sourceTree = "<group>"; };
|
||||
95498DBB0AE3812F006B5F81 /* VLSoundSched.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = VLSoundSched.h; path = Sources/VLSoundSched.h; sourceTree = "<group>"; };
|
||||
95498DBC0AE3812F006B5F81 /* VLSoundSched.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = VLSoundSched.mm; path = Sources/VLSoundSched.mm; sourceTree = "<group>"; };
|
||||
954BBD840AEDDE5300BBFD5F /* VLAppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLAppController.h; path = Sources/VLAppController.h; sourceTree = "<group>"; };
|
||||
954BBD850AEDDE5300BBFD5F /* VLAppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = VLAppController.mm; path = Sources/VLAppController.mm; sourceTree = "<group>"; };
|
||||
954BBD980AEDE81500BBFD5F /* VLPitchTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLPitchTransformer.h; path = Sources/VLPitchTransformer.h; sourceTree = "<group>"; };
|
||||
954BBD990AEDE81500BBFD5F /* VLPitchTransformer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = VLPitchTransformer.mm; path = Sources/VLPitchTransformer.mm; sourceTree = "<group>"; };
|
||||
955E58E3095658AB0045FDA5 /* VLModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLModel.h; path = Sources/VLModel.h; sourceTree = "<group>"; };
|
||||
955E58E4095658AB0045FDA5 /* VLModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VLModel.cpp; path = Sources/VLModel.cpp; sourceTree = "<group>"; };
|
||||
955E595C0957C0FC0045FDA5 /* TVLChord */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TVLChord; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -207,6 +213,10 @@
|
|||
95F5F50E0ADCC433003980B2 /* VLXMLDocument.mm */,
|
||||
953722650AE9F0E100B6E483 /* VLLilypondDocument.h */,
|
||||
953722660AE9F0E100B6E483 /* VLLilypondDocument.mm */,
|
||||
954BBD840AEDDE5300BBFD5F /* VLAppController.h */,
|
||||
954BBD850AEDDE5300BBFD5F /* VLAppController.mm */,
|
||||
954BBD980AEDE81500BBFD5F /* VLPitchTransformer.h */,
|
||||
954BBD990AEDE81500BBFD5F /* VLPitchTransformer.mm */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
|
@ -398,6 +408,8 @@
|
|||
95F5F50F0ADCC433003980B2 /* VLXMLDocument.mm in Sources */,
|
||||
95498DBD0AE3812F006B5F81 /* VLSoundSched.mm in Sources */,
|
||||
953722670AE9F0E100B6E483 /* VLLilypondDocument.mm in Sources */,
|
||||
954BBD860AEDDE5300BBFD5F /* VLAppController.mm in Sources */,
|
||||
954BBD9A0AEDE81500BBFD5F /* VLPitchTransformer.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user