Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/Classes/MyDocument.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 195 - (show annotations) (download) (as text)
Sun Mar 29 11:19:06 2020 UTC (4 years, 2 months ago) by toshinagata1964
File MIME type: text/x-chdr
File size: 11615 byte(s)
Handling of editing range is improved (especially empty time range is selected in TimeChartView)
1 //
2 // MyDocuments.h
3 //
4 // Created by Toshi Nagata.
5 /*
6 Copyright (c) 2000-2017 Toshi Nagata. All rights reserved.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation version 2 of the License.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 */
17
18 #import <Cocoa/Cocoa.h>
19 #import "MDHeaders.h"
20
21 @class MyMIDISequence;
22 @class MDEventObject;
23 @class MDTrackObject;
24 @class IntGroupObject;
25 @class MDSelectionObject;
26 @class GraphicWindowController;
27
28 // Track was modified; info = { @"track", trackNo (int) }
29 extern NSString *MyDocumentTrackModifiedNotification;
30
31 // Track was inserted; info = { @"track", trackNo (int) }
32 extern NSString *MyDocumentTrackInsertedNotification;
33
34 // Track was deleted; info = { @"track", trackNo (int) }
35 extern NSString *MyDocumentTrackDeletedNotification;
36
37 // Track is playing; info = { @"position", positionInQuarters (float) }
38 extern NSString *MyDocumentPlayPositionNotification;
39
40 // Selection has been changed; info = { @"keys", NSArray of track numbers (plus some other info) }
41 extern NSString *MyDocumentSelectionDidChangeNotification;
42
43 // Editing range has been changed; info = none
44 extern NSString *MyDocumentEditingRangeDidChangeNotification;
45
46 // Track has stopped playing; info = none
47 //extern NSString *MyDocumentStopPlayingNotification;
48
49 // Pasteboard types
50 extern NSString *MySequencePBoardType;
51 extern NSString *MySeqCatalogPBoardType;
52
53 typedef enum MyDocumentModifyMode {
54 MyDocumentModifyNone = 0,
55 MyDocumentModifySet,
56 MyDocumentModifyAdd,
57 MyDocumentModifyMultiply
58 } MyDocumentModifyMode;
59
60 @interface MyDocument : NSDocument
61 {
62 @private
63 NSData *myData;
64 MyMIDISequence *myMIDISequence;
65 NSMutableArray *selections;
66 GraphicWindowController *mainWindowController;
67
68 // Editing range
69 MDTickType startEditingRange, endEditingRange;
70
71 // Selection stack (for undo/redo selection)
72 NSMutableArray *selectionStack;
73 int selectionStackPointer;
74 NSMutableDictionary *selectionQueue;
75
76 // Modified tracks (for sending track-modify-notification at the end of the runloop)
77 // An array of NSNumbers (representing the track numbers)
78 NSMutableArray *modifiedTracks;
79
80 // Destination List
81 // The devices that have once been used in this document is remembered
82 // until this document is closed
83 // Updated in getDestinationNames (and only there)
84 NSArray *destinationNames;
85
86 // Script menu
87 // NSMutableArray *scriptMenuInfos;
88 }
89 - (id)init;
90 - (MyMIDISequence *)myMIDISequence;
91 - (NSString *)tuneName;
92
93 - (void)lockMIDISequence;
94 - (void)unlockMIDISequence;
95
96 - (GraphicWindowController *)mainWindowController;
97 - (void)createWindowForTracks: (NSArray *)tracks ofType: (NSString *)windowType;
98
99 - (NSArray *)getDestinationNames;
100
101 - (void)enqueueTrackModifiedNotification: (int32_t)trackNo;
102 - (void)enqueueTrackAttributeChangedNotification: (int32_t)trackNo;
103 - (void)postTrackModifiedNotification: (NSNotification *)notification;
104 - (void)postPlayPositionNotification: (MDTickType)tick;
105 //- (void)postSelectionDidChangeNotification: (int32_t)trackNo selectionChange: (IntGroupObject *)set sender: (id)sender;
106 //- (void)postStopPlayingNotification;
107
108 // Action methods for undo/redo support
109 - (BOOL)insertTrack: (MDTrackObject *)trackObj atIndex: (int32_t)trackNo;
110 - (BOOL)deleteTrackAt: (int32_t)trackNo;
111
112 - (BOOL)setRecordFlagOnTrack: (int32_t)trackNo flag: (int)flag;
113 - (BOOL)setMuteFlagOnTrack: (int32_t)trackNo flag: (int)flag;
114 - (BOOL)setSoloFlagOnTrack: (int32_t)trackNo flag: (int)flag;
115
116 - (BOOL)insertEvent: (MDEventObject *)eventObj toTrack: (int32_t)trackNo;
117 - (BOOL)deleteEventAt: (int32_t)position fromTrack: (int32_t)trackNo;
118 - (BOOL)replaceEvent: (MDEventObject *)eventObj inTrack: (int32_t)trackNo;
119
120 - (BOOL)insertMultipleEvents: (MDTrackObject *)trackObj at: (IntGroupObject *)pointSet toTrack: (int32_t)trackNo selectInsertedEvents: (BOOL)flag insertedPositions: (IntGroup **)outPtr;
121 - (BOOL)deleteMultipleEventsAt: (IntGroupObject *)pointSet fromTrack: (int32_t)trackNo deletedEvents: (MDTrack **)outPtr;
122 - (BOOL)duplicateMultipleEventsAt: (IntGroupObject *)pointSet ofTrack: (int32_t)trackNo selectInsertedEvents: (BOOL)flag;
123
124 // Modify action methods; theData is one of the following, NSNumber, NSData (an array of MDTickType, short or float) or NSArray.
125 - (BOOL)modifyTick: (id)theData ofMultipleEventsAt: (IntGroupObject *)pointSet inTrack: (int32_t)trackNo mode: (MyDocumentModifyMode)mode destinationPositions: (id)destPositions setSelection: (BOOL)setSelection;
126 + (BOOL)modifyTick: (id)theData ofMultipleEventsAt: (IntGroupObject *)pointSet forMDTrack: (MDTrack *)track inDocument: (id)doc mode: (MyDocumentModifyMode)mode destinationPositions: (id)destPositions setSelection: (BOOL)setSelection;
127 - (BOOL)modifyCodes: (id)theData ofMultipleEventsAt: (IntGroupObject *)pointSet inTrack: (int32_t)trackNo mode: (MyDocumentModifyMode)mode;
128 + (BOOL)modifyCodes: (id)theData ofMultipleEventsAt: (IntGroupObject *)pointSet forMDTrack: (MDTrack *)track inDocument: (MyDocument *)doc mode: (MyDocumentModifyMode)mode;
129 - (BOOL)modifyDurations: (id)theData ofMultipleEventsAt: (IntGroupObject *)pointSet inTrack: (int32_t)trackNo mode: (MyDocumentModifyMode)mode;
130 + (BOOL)modifyDurations: (id)theData ofMultipleEventsAt: (IntGroupObject *)pointSet forMDTrack: (MDTrack *)track inDocument: (MyDocument *)doc mode: (MyDocumentModifyMode)mode;
131 - (BOOL)modifyData: (id)theData forEventKind: (unsigned char)eventKind ofMultipleEventsAt: (IntGroupObject *)pointSet inTrack: (int32_t)trackNo mode: (MyDocumentModifyMode)mode;
132 + (BOOL)modifyData: (id)theData forEventKind: (unsigned char)eventKind ofMultipleEventsAt: (IntGroupObject *)pointSet forMDTrack: (MDTrack *)track inDocument: (MyDocument *)doc mode: (MyDocumentModifyMode)mode;
133
134 - (const MDEvent *)eventAtPosition: (int32_t)position inTrack: (int32_t)trackNo;
135
136 - (int32_t)changeTick: (int32_t)tick atPosition: (int32_t)position inTrack: (int32_t)trackNo originalPosition: (int32_t)pos1;
137 - (BOOL)changeChannel: (int)channel atPosition: (int32_t)position inTrack: (int32_t)trackNo;
138 - (BOOL)changeDuration: (int32_t)duration atPosition: (int32_t)position inTrack: (int32_t)trackNo;
139 - (BOOL)changeTrackDuration: (int32_t)duration ofTrack: (int32_t)trackNo;
140 - (BOOL)changeValue: (MDEventFieldDataWhole)wholeValue ofType: (int)code atPosition: (int32_t)position inTrack: (int32_t)trackNo;
141 - (BOOL)changeMessage: (NSData *)data atPosition: (int32_t)position inTrack: (int32_t)trackNo;
142
143 - (BOOL)scaleTimeFrom:(MDTickType)startTick to:(MDTickType)endTick newDuration:(MDTickType)newDuration insertTempo:(BOOL)insertTempo setSelection:(BOOL)setSelection;
144
145 - (BOOL)changeDevice: (NSString *)deviceName forTrack: (int32_t)trackNo;
146 //- (BOOL)changeDeviceNumber: (int32_t)deviceNumber forTrack: (int32_t)trackNo;
147 - (BOOL)changeTrackChannel: (int)channel forTrack: (int32_t)trackNo;
148 - (BOOL)changeTrackName: (NSString *)trackName forTrack: (int32_t)trackNo;
149
150 - (BOOL)setSelection: (MDSelectionObject *)set inTrack: (int32_t)trackNo sender: (id)sender;
151 - (BOOL)toggleSelection: (MDSelectionObject *)set inTrack: (int32_t)trackNo sender: (id)sender;
152 - (BOOL)selectEventAtPosition: (int32_t)position inTrack: (int32_t)trackNo sender: (id)sender;
153 - (BOOL)unselectEventAtPosition: (int32_t)position inTrack: (int32_t)trackNo sender: (id)sender;
154 - (BOOL)selectAllEventsInTrack: (int32_t)trackNo sender: (id)sender;
155 - (BOOL)unselectAllEventsInTrack: (int32_t)trackNo sender: (id)sender;
156 - (BOOL)unselectAllEventsInAllTracks: (id)sender;
157 - (BOOL)addSelection: (IntGroupObject *)set inTrack: (int32_t)trackNo sender: (id)sender;
158 - (BOOL)isSelectedAtPosition: (int32_t)position inTrack: (int32_t)trackNo;
159
160 // Notification handlers
161 - (void)selectionWillChange: (NSNotification *)notification;
162 - (void)trackModified: (NSNotification *)notification;
163 - (void)trackInserted: (NSNotification *)notification;
164 - (void)trackDeleted: (NSNotification *)notification;
165 - (void)documentSelectionDidChange: (NSNotification *)notification;
166
167 - (void)getEditingRangeStart: (MDTickType *)startTick end: (MDTickType *)endTick;
168 - (void)setEditingRangeStart: (MDTickType)startTick end: (MDTickType)endTick;
169 - (void)getSelectionStartTick: (MDTickType *)startTickPtr endTick: (MDTickType *)endTickPtr editableTracksOnly: (BOOL)flag;
170
171 - (MDSelectionObject *)selectionOfTrack: (int32_t)trackNo;
172
173 - (MDSelectionObject *)eventSetInTrack: (int32_t)trackNo eventKind: (int)eventKind eventCode: (int)eventCode fromTick: (MDTickType)fromTick toTick: (MDTickType)toTick fromData: (float)fromData toData: (float)toData inPointSet: (IntGroupObject *)pointSet;
174 - (int32_t)countMIDIEventsForTrack: (int32_t)index inSelection: (MDSelectionObject *)sel;
175 - (BOOL)isSelectionEmptyInEditableTracks:(BOOL)editableOnly;
176
177 - (float)timebase;
178 - (void)setTimebase:(float)timebase;
179
180 // Color management
181 - (NSColor *)defaultColorForTrack: (int)track enabled: (BOOL)flag;
182 - (NSColor *)colorForTrack: (int)track enabled: (BOOL)flag;
183 - (void)changeColor: (NSColor *)color forTrack: (int)track enableUndo: (BOOL)enableUndo;
184 + (NSColor *)colorForEditingRange;
185 + (NSColor *)colorForSelectingRange;
186
187 // Track attributes
188 - (NSData *)getTrackAttributes;
189 - (void)setTrackAttributes: (NSData *)data;
190 - (MDTrackAttribute)trackAttributeForTrack: (int32_t)trackNo;
191 - (void)setTrackAttribute: (MDTrackAttribute)attr forTrack: (int32_t)trackNo;
192 - (BOOL)isTrackSelected: (int32_t)trackNo;
193 - (void)setIsTrackSelected: (int32_t)trackNo flag: (BOOL)flag;
194
195 // Pasteboard supports
196 - (BOOL)copyWithSelections: (MDSelectionObject **)selArray rangeStart: (MDTickType)startTick rangeEnd: (MDTickType)endTick;
197 - (BOOL)isSequenceInPasteboard;
198 - (BOOL)getPasteboardSequence: (MDSequence **)outSequence catalog: (MDCatalog **)outCatalog;
199 - (int)doPaste: (MDSequence *)seq toTracks: (int *)trackList rangeStart: (MDTickType)startTick rangeEnd: (MDTickType)endTick mergeFlag: (BOOL)mergeFlag;
200
201 // Playing control (from main menu)
202 - (IBAction)performStartPlay: (id)sender;
203 - (IBAction)performStopPlay: (id)sender;
204 - (IBAction)performPausePlay: (id)sender;
205 - (IBAction)performStartMIDIRecording: (id)sender;
206 - (IBAction)performStartAudioRecording: (id)sender;
207
208 // General editing
209 - (IBAction)insertBlankTime:(id)sender;
210 - (IBAction)deleteSelectedTime:(id)sender;
211 - (IBAction)scaleSelectedTime:(id)sender;
212 - (IBAction)quantizeSelectedEvents:(id)sender;
213 - (IBAction)getEditingRangeFromPasteboard:(id)sender;
214
215 // Recording
216 - (BOOL)startRecording;
217 - (BOOL)finishRecording;
218 - (BOOL)startAudioRecording;
219 - (BOOL)finishAudioRecording;
220
221 // Structure to keep track of MyDocument-MDTrack correspondence
222 // When a track is inserted to or deleted from a document, all registered
223 // MyDocumentTrackInfo are scanned and the information is updated.
224 // No ownership of the memory is claimed; registerDocumentTrackInfo only
225 // keeps the pointer, and unregisterDocumentTrackInfo only removes the pointer
226 // from the internal buffer. If a MyDocumentTrackInfo block is freed without
227 // unregistering, disaster will come. Be careful!
228
229 typedef struct MyDocumentTrackInfo {
230 MyDocument *doc;
231 MDTrack *track;
232 int num;
233 } MyDocumentTrackInfo;
234
235 + (void)registerDocumentTrackInfo: (MyDocumentTrackInfo *)info;
236 + (void)unregisterDocumentTrackInfo: (MyDocumentTrackInfo *)info;
237
238 // Script menu
239 // - (NSMutableArray *)scriptMenuInfos;
240 // - (void)doDocumentScriptCommand: (id)sender;
241
242 @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26