• R/O
  • SSH
  • HTTPS

alchemusica: Commit


Commit MetaInfo

Revisión145 (tree)
Tiempo2017-11-11 22:52:18
Autortoshinagata1964

Log Message

MIDI note transpose is implemented for MIDI thru and recording

Cambiar Resumen

Diferencia incremental

--- trunk/Classes/MyMIDISequence.h (revision 144)
+++ trunk/Classes/MyMIDISequence.h (revision 145)
@@ -57,9 +57,10 @@
5757 *MyRecordingInfoRecordingModeKey, // int; kRecordingMode{CountOff, WaitForNote}
5858 *MyRecordingInfoCountOffNumberKey, // int; count off number
5959 *MyRecordingInfoBarBeatFlagKey, // bool; countOffNumber is bar (YES) or beat (NO)
60+ *MyRecordingInfoMIDITransposeKey, // int; MIDI transpose
6061 *MyRecordingInfoAudioRecordingFormatKey, // int; kAudioRecording{AIFF,WAV}Format
6162 *MyRecordingInfoAudioBitRateKey, // float; audio bit rate
62- *MyRecordingInfoAudioChannelFormatKey; // int; kAudioRecording{Mono,Stereo}Format
63+ *MyRecordingInfoAudioChannelFormatKey; // int; kAudioRecording{Mono,Stereo}Format
6364
6465 extern NSString *MyRecordingInfoFileExtensionForFormat(int format);
6566
--- trunk/Classes/MyMIDISequence.m (revision 144)
+++ trunk/Classes/MyMIDISequence.m (revision 145)
@@ -40,7 +40,8 @@
4040 *MyRecordingInfoRecordingModeKey = @"recordingMode",
4141 *MyRecordingInfoCountOffNumberKey = @"countOffNumber",
4242 *MyRecordingInfoBarBeatFlagKey = @"barBeatFlag",
43- *MyRecordingInfoAudioRecordingFormatKey = @"audioRecordingFormat",
43+ *MyRecordingInfoMIDITransposeKey = @"MIDItranspose",
44+ *MyRecordingInfoAudioRecordingFormatKey = @"audioRecordingFormat",
4445 *MyRecordingInfoAudioBitRateKey = @"audioBitRate",
4546 *MyRecordingInfoAudioChannelFormatKey = @"audioChannelFormat";
4647
@@ -104,6 +105,7 @@
104105 [NSNumber numberWithInt: 0], MyRecordingInfoRecordingModeKey,
105106 [NSNumber numberWithInt: 0], MyRecordingInfoCountOffNumberKey,
106107 [NSNumber numberWithBool: NO], MyRecordingInfoBarBeatFlagKey,
108+ [NSNumber numberWithInt: 0], MyRecordingInfoMIDITransposeKey,
107109 [NSNumber numberWithInt: kAudioRecordingAIFFFormat], MyRecordingInfoAudioRecordingFormatKey,
108110 [NSNumber numberWithFloat: 44100.0], MyRecordingInfoAudioBitRateKey,
109111 [NSNumber numberWithInt: kAudioRecordingStereoFormat], MyRecordingInfoAudioChannelFormatKey,
@@ -392,7 +394,7 @@
392394 - (MDStatus)startMIDIRecording
393395 {
394396 int32_t dev;
395- int ch;
397+ int ch, trans;
396398 MDTickType tick;
397399 NSString *destDevice;
398400 if (mySequence == NULL || myPlayer == NULL)
@@ -405,6 +407,8 @@
405407 else dev = -1;
406408 ch = [[recordingInfo valueForKey: MyRecordingInfoDestinationChannelKey] intValue];
407409 MDPlayerSetMIDIThruDeviceAndChannel(dev, ch);
410+ trans = [[recordingInfo valueForKey: MyRecordingInfoMIDITransposeKey] intValue];
411+ MDPlayerSetMIDIThruTranspose(trans);
408412 tick = (MDTickType)[[recordingInfo valueForKey: MyRecordingInfoStartTickKey] doubleValue];
409413 if (tick >= 0 && tick < kMDMaxTick)
410414 MDPlayerJumpToTick(myPlayer, tick);
--- trunk/Classes/RecordPanelController.h (revision 144)
+++ trunk/Classes/RecordPanelController.h (revision 145)
@@ -43,7 +43,9 @@
4343 IBOutlet NSSlider *audioVolumeSlider;
4444 IBOutlet NSLevelIndicator *audioLeftLevel;
4545 IBOutlet NSLevelIndicator *audioRightLevel;
46-
46+ IBOutlet NSPopUpButton *transposeOctavePopUp;
47+ IBOutlet NSPopUpButton *transposeNotePopUp;
48+
4749 BOOL stopModalFlag;
4850 BOOL isAudio;
4951 MyDocument *myDocument;
--- trunk/Classes/RecordPanelController.m (revision 144)
+++ trunk/Classes/RecordPanelController.m (revision 145)
@@ -67,23 +67,12 @@
6767 }
6868
6969 if (!isAudio) {
70- [destinationDevicePopUp selectItemWithTitle: [info valueForKey: MyRecordingInfoDestinationDeviceKey]];
71- }
72-// [destinationDevicePopUp selectItemWithTitle: [info valueForKey: (isAudio ? MyRecordingInfoDestinationAudioDeviceKey : MyRecordingInfoDestinationDeviceKey)]];
73-/* if (isAudio) {
74- [playThruCheckbox setState: [[info valueForKey: MyRecordingInfoAudioPlayThroughKey] boolValue]];
75- } */
76-
77- if (!isAudio) {
70+ [destinationDevicePopUp selectItemWithTitle: [info valueForKey: MyRecordingInfoDestinationDeviceKey]];
7871 ival = [[info valueForKey: MyRecordingInfoTargetTrackKey] intValue];
7972 if (ival > 0 && ival < [seq trackCount]) {
8073 [destinationTrackPopUp selectItemAtIndex: ival - 1];
81- // [destinationDevicePopUp setEnabled: NO];
82- // [midiChannelPopUp setEnabled: NO];
8374 } else {
8475 [destinationTrackPopUp selectItemAtIndex: [destinationTrackPopUp numberOfItems] - 1];
85- // [destinationDevicePopUp setEnabled: YES];
86- // [midiChannelPopUp setEnabled: YES];
8776 }
8877 ival = [[info valueForKey: MyRecordingInfoDestinationChannelKey] intValue];
8978 [midiChannelPopUp selectItemAtIndex: ival];
@@ -98,6 +87,9 @@
9887 [barBeatPopUp setEnabled: NO];
9988 [barBeatText setEnabled: NO];
10089 }
90+ ival = [[info valueForKey: MyRecordingInfoMIDITransposeKey] intValue];
91+ [transposeOctavePopUp selectItemAtIndex:8 - ((ival + 48) / 12)];
92+ [transposeNotePopUp selectItemAtIndex:((ival + 48) % 12)];
10193 }
10294
10395 theTick = [[info valueForKey: MyRecordingInfoStartTickKey] doubleValue];
@@ -398,7 +390,12 @@
398390 [info setValue: [NSNumber numberWithInt: tag] forKey: MyRecordingInfoRecordingModeKey];
399391 } else if (sender == barBeatPopUp) {
400392 [info setValue: [NSNumber numberWithBool: (tag == 0)] forKey: MyRecordingInfoBarBeatFlagKey];
401- } else if (sender == audioFormatPopUp) {
393+ } else if (sender == transposeOctavePopUp || sender == transposeNotePopUp) {
394+ tag = (4 - [transposeOctavePopUp indexOfSelectedItem]) * 12;
395+ tag += [transposeNotePopUp indexOfSelectedItem];
396+ [info setValue: [NSNumber numberWithInt: tag] forKey: MyRecordingInfoMIDITransposeKey];
397+ MDPlayerSetMIDIThruTranspose(tag);
398+ } else if (sender == audioFormatPopUp) {
402399 [info setValue: [NSNumber numberWithInt: tag] forKey: MyRecordingInfoAudioRecordingFormatKey];
403400 } else if (sender == audioSampleRatePopUp) {
404401 float fval = [[sender titleOfSelectedItem] floatValue];
@@ -507,7 +504,7 @@
507504
508505 - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
509506 {
510- editingText = control;
507+ editingText = (NSTextField *)control;
511508 return YES;
512509 }
513510
--- trunk/MD_package/MDPlayer_MacOSX.c (revision 144)
+++ trunk/MD_package/MDPlayer_MacOSX.c (revision 145)
@@ -203,6 +203,7 @@
203203 //static MDDestinationInfo *sMIDIThruDestination = NULL;
204204 static int32_t sMIDIThruDevice = -1;
205205 static int sMIDIThruChannel = 0; /* 0..15; if 16, then incoming channel number is kept */
206+static int sMIDIThruTranspose = 0;
206207
207208 /* Minimum interval of interrupts */
208209 #define kMDPlayerMinimumInterval 50000 /* 50 msec */
@@ -1050,6 +1051,16 @@
10501051 }
10511052 packet = (MIDIPacket *)pktlist->packet;
10521053 for (i = 0; i < pktlist->numPackets; i++, packet = MIDIPacketNext(packet)) {
1054+ if (sMIDIThruTranspose != 0) {
1055+ /* Transpose */
1056+ for (j = 0; j < packet->length; j++) {
1057+ if (packet->data[j] >= 0x80 && packet->data[j] <= 0x9f) {
1058+ n = packet->data[j + 1] + sMIDIThruTranspose;
1059+ if (n >= 0 && n < 128)
1060+ packet->data[j + 1] = n;
1061+ }
1062+ }
1063+ }
10531064 if (recordingFlag) {
10541065 if (packet->timeStamp != 0) {
10551066 myTimeStamp = ConvertHostTimeToMDTimeType(packet->timeStamp) - sRecordingPlayer->startTime;
@@ -1894,7 +1905,7 @@
18941905 if (MDSequenceCreateMutex(inPlayer->sequence))
18951906 return kMDErrorOnSequenceMutex;
18961907
1897- inPlayer->startTime = GetHostTimeInMDTimeType() - inPlayer->time + inPlayer->countOffDuration;
1908+ inPlayer->startTime = GetHostTimeInMDTimeType() - inPlayer->time;
18981909 inPlayer->countOffEndTime = inPlayer->time;
18991910 if (inPlayer->isRecording && inPlayer->countOffDuration > 0) {
19001911 /* Look for the earliest metronome tick after start time */
@@ -1904,6 +1915,7 @@
19041915 MDEvent *ep = MDCalibratorGetEvent(inPlayer->calib, NULL, kMDEventTimeSignature, -1);
19051916 MDTickType sigtick = (ep == NULL ? 0 : MDGetTick(ep));
19061917 int32_t timebase = MDSequenceGetTimebase(inPlayer->sequence);
1918+ inPlayer->startTime += inPlayer->countOffDuration;
19071919 MDEventCalculateMetronomeBarAndBeat(ep, timebase, &bar, &beat);
19081920 tick -= sigtick;
19091921 barnum = tick / bar;
@@ -2152,14 +2164,20 @@
21522164 void
21532165 MDPlayerSetMIDIThruDeviceAndChannel(int32_t dev, int ch)
21542166 {
2155- // if (sMIDIThruDestination != NULL)
2156- // MDPlayerReleaseDestinationInfo(sMIDIThruDestination);
2157- // sMIDIThruDestination = MDPlayerNewDestinationInfo(dev);
21582167 sMIDIThruDevice = dev;
21592168 sMIDIThruChannel = ch;
21602169 }
21612170
21622171 /* --------------------------------------
2172+ ・ MDPlayerSetMIDIThruTranspose
2173+ -------------------------------------- */
2174+void
2175+MDPlayerSetMIDIThruTranspose(int transpose)
2176+{
2177+ sMIDIThruTranspose = transpose;
2178+}
2179+
2180+/* --------------------------------------
21632181 ・ MDPlayerSetCountOffSettings
21642182 -------------------------------------- */
21652183 void
--- trunk/MD_package/MDPlayer_MacOSX.h (revision 144)
+++ trunk/MD_package/MDPlayer_MacOSX.h (revision 145)
@@ -81,6 +81,7 @@
8181 MDTickType MDPlayerGetTick(MDPlayer *inPlayer);
8282
8383 void MDPlayerSetMIDIThruDeviceAndChannel(int32_t dev, int ch);
84+void MDPlayerSetMIDIThruTranspose(int transpose);
8485 void MDPlayerSetCountOffSettings(MDPlayer *inPlayer, MDTimeType duration, MDTimeType bar, MDTimeType beat);
8586 MDStatus MDPlayerBacktrackEvents(MDPlayer *inPlayer, MDTickType inTick, const int32_t *inEventType, const int32_t *inEventTypeLastOnly);
8687 int MDPlayerSendRawMIDI(MDPlayer *player, const unsigned char *p, int size, int destDevice, MDTimeType scheduledTime);
Show on old repository browser