• R/O
  • SSH
  • HTTPS

alchemusica: 提交


Commit MetaInfo

修订版22 (tree)
时间2012-01-21 17:42:50
作者toshinagata1964

Log Message

Quantize selected events: missing files are added

更改概述

差异

--- trunk/Classes/QuantizePanelController.h (nonexistent)
+++ trunk/Classes/QuantizePanelController.h (revision 22)
@@ -0,0 +1,28 @@
1+//
2+// QuantizePanelController.h
3+// Alchemusica
4+//
5+// Created by Toshi Nagata on 12/01/14.
6+// Copyright 2012 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import <Cocoa/Cocoa.h>
10+
11+extern NSString *QuantizeNoteKey, *QuantizeStrengthKey, *QuantizeSwingKey;
12+
13+@interface QuantizePanelController : NSWindowController {
14+ float timebase;
15+ IBOutlet NSPopUpButton *unitNotePopUp;
16+ IBOutlet NSTextField *unitText;
17+ IBOutlet NSSlider *strengthSlider;
18+ IBOutlet NSTextField *strengthText;
19+ IBOutlet NSSlider *swingSlider;
20+ IBOutlet NSTextField *swingText;
21+}
22+- (void)setTimebase:(float)timebase;
23+- (IBAction)unitChanged:(id)sender;
24+- (IBAction)strengthChanged:(id)sender;
25+- (IBAction)swingChanged:(id)sender;
26+- (IBAction)okPressed:(id)sender;
27+- (IBAction)cancelPressed:(id)sender;
28+@end
--- trunk/Classes/QuantizePanelController.m (nonexistent)
+++ trunk/Classes/QuantizePanelController.m (revision 22)
@@ -0,0 +1,141 @@
1+//
2+// QuantizePanelController.m
3+// Alchemusica
4+//
5+// Created by Toshi Nagata on 12/01/14.
6+// Copyright 2012 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import "QuantizePanelController.h"
10+#import "MyAppController.h"
11+
12+NSString
13+*QuantizeNoteKey = @"quantize.note", /* Expressed internally as timebase = 480 */
14+*QuantizeStrengthKey = @"quantize.strength",
15+*QuantizeSwingKey = @"quantize.swing";
16+
17+@implementation QuantizePanelController
18+
19+- (id)init
20+{
21+ self = [super initWithWindowNibName:@"QuantizePanel"];
22+ if (self) {
23+ timebase = 480.0;
24+ }
25+ return self;
26+}
27+
28+- (void)updateDisplay
29+{
30+ id obj;
31+ int ival;
32+ float fval;
33+ obj = MyAppCallback_getObjectGlobalSettings(QuantizeNoteKey);
34+ if (obj == nil) {
35+ obj = [NSNumber numberWithFloat:480.0];
36+ MyAppCallback_setObjectGlobalSettings(QuantizeNoteKey, obj);
37+ }
38+ fval = [obj floatValue];
39+ for (ival = 0; ival < 18; ival++) {
40+ if ([[unitNotePopUp itemAtIndex:ival] tag] == fval) {
41+ [unitNotePopUp selectItemAtIndex:ival];
42+ break;
43+ }
44+ }
45+ if (ival == 18)
46+ [unitNotePopUp selectItemAtIndex:-1];
47+ ival = floor(fval * timebase / 480.0 + 0.5);
48+ [unitText setIntValue:ival];
49+
50+ obj = MyAppCallback_getObjectGlobalSettings(QuantizeStrengthKey);
51+ if (obj == nil) {
52+ obj = [NSNumber numberWithFloat:0.5];
53+ MyAppCallback_setObjectGlobalSettings(QuantizeStrengthKey, obj);
54+ }
55+ fval = [obj floatValue];
56+ [strengthSlider setFloatValue:fval];
57+ [strengthText setFloatValue:fval];
58+
59+ obj = MyAppCallback_getObjectGlobalSettings(QuantizeSwingKey);
60+ if (obj == nil) {
61+ obj = [NSNumber numberWithFloat:0.0];
62+ MyAppCallback_setObjectGlobalSettings(QuantizeSwingKey, obj);
63+ }
64+ fval = [obj floatValue];
65+ [swingSlider setFloatValue:fval];
66+ [swingText setFloatValue:fval];
67+}
68+
69+- (void)windowDidLoad
70+{
71+ NSMenu *menu;
72+ NSMenuItem *menuItem;
73+ int i, j;
74+ [super windowDidLoad];
75+ menu = [unitNotePopUp menu];
76+ for (i = 0; i < 3; i++) {
77+ static NSString *fmt[] = {@"note%d.png", @"note%dd.png", @"note%d_3.png"};
78+ static int notelen[] = {1920, 2880, 1280};
79+ for (j = 1; j <= 32; j *= 2) {
80+ menuItem = [[[NSMenuItem allocWithZone: [self zone]] initWithTitle: @"" action: nil keyEquivalent: @""] autorelease];
81+ [menuItem setImage: [NSImage imageNamed: [NSString stringWithFormat: fmt[i], j]]];
82+ [menuItem setTag:notelen[i] / j]; /* Note length for timebase = 480 */
83+ [menu addItem: menuItem];
84+ }
85+ }
86+ [self updateDisplay];
87+}
88+
89+- (void)setTimebase:(float)newTimebase
90+{
91+ timebase = newTimebase;
92+ [self updateDisplay];
93+}
94+
95+- (IBAction)unitChanged:(id)sender
96+{
97+ float fval;
98+ if (sender == unitNotePopUp)
99+ fval = [[sender selectedItem] tag];
100+ else if (sender == unitText)
101+ fval = [sender floatValue] * 480.0 / timebase;
102+ else return;
103+ MyAppCallback_setObjectGlobalSettings(QuantizeNoteKey, [NSNumber numberWithFloat:fval]);
104+ [self updateDisplay];
105+}
106+
107+- (IBAction)strengthChanged:(id)sender
108+{
109+ float fval;
110+ fval = [sender floatValue];
111+ if (fval < 0.0)
112+ fval = 0.0;
113+ if (fval > 1.0)
114+ fval = 1.0;
115+ MyAppCallback_setObjectGlobalSettings(QuantizeStrengthKey, [NSNumber numberWithFloat:fval]);
116+ [self updateDisplay];
117+}
118+
119+- (IBAction)swingChanged:(id)sender
120+{
121+ float fval;
122+ fval = [sender floatValue];
123+ if (fval < 0.0)
124+ fval = 0.0;
125+ if (fval > 1.0)
126+ fval = 1.0;
127+ MyAppCallback_setObjectGlobalSettings(QuantizeSwingKey, [NSNumber numberWithFloat:fval]);
128+ [self updateDisplay];
129+}
130+
131+- (IBAction)okPressed:(id)sender
132+{
133+ [NSApp stopModal];
134+}
135+
136+- (IBAction)cancelPressed:(id)sender
137+{
138+ [NSApp abortModal];
139+}
140+
141+@end
Show on old repository browser