• R/O
  • SSH
  • HTTPS

alchemusica: 提交


Commit MetaInfo

修订版27 (tree)
时间2012-08-15 17:05:13
作者toshinagata1964

Log Message

Handling of MIDI/Audio recording is improved; specifically, policy of stop MIDI play is made clear

更改概述

差异

--- trunk/Classes/AudioSettingsPanelController.m (revision 26)
+++ trunk/Classes/AudioSettingsPanelController.m (revision 27)
@@ -96,7 +96,7 @@
9696 [view selectItemWithTag: n + 1];
9797 if (n >= 0 || !isInput) {
9898 view = [self viewWithTag: kPanKnobBase + tagOffset];
99- [view setEnabled: YES];
99+ [view setEnabled: (isInput != 0)];
100100 view = [self viewWithTag: kVolumeSliderBase + tagOffset];
101101 [view setEnabled: YES];
102102 view = [self viewWithTag: kLeftLevelIndicatorBase + tagOffset];
--- trunk/Classes/PlayingViewController.m (revision 26)
+++ trunk/Classes/PlayingViewController.m (revision 27)
@@ -142,7 +142,11 @@
142142 [pauseButton setEnabled: YES];
143143 [ffButton setEnabled: YES];
144144 [rewindButton setEnabled: YES];
145- recordingPlayer = MDPlayerRecordingPlayer();
145+ if (isRecording)
146+ [recordButton setState:NSOnState];
147+ else
148+ [recordButton setState:NSOffState];
149+ /* recordingPlayer = MDPlayerRecordingPlayer();
146150 if (recordingPlayer == NULL) {
147151 [recordButton setEnabled: YES];
148152 [recordButton setState: NSOffState];
@@ -151,7 +155,7 @@
151155 [recordButton setState: (MDPlayerIsRecording(player) ? NSOnState : NSOffState)];
152156 } else {
153157 [recordButton setEnabled: NO];
154- }
158+ } */
155159 if (status == kMDPlayer_playing || status == kMDPlayer_exhausted) {
156160 playingOrRecording = YES;
157161 [playButton setState: NSOnState];
@@ -399,25 +403,28 @@
399403 if (status == kMDPlayer_playing || status == kMDPlayer_exhausted) {
400404 currentTime = MDPlayerGetTime(player); /* Update the current time */
401405 [self refreshTimeDisplay];
402- #if 0
403406 if (isRecording) {
404407 NSDictionary *info = [seq recordingInfo];
405- if (isPlayerRecording) {
408+ // if (isPlayerRecording) {
406409 // Check for automatic stop recording
407410 if ([[info valueForKey: MyRecordingInfoStopFlagKey] boolValue]) {
408411 MDTickType currentTick = MDCalibratorTimeToTick(calibrator, currentTime);
409412 if (currentTick > [[info valueForKey: MyRecordingInfoStopTickKey] doubleValue]) {
410413 // Stop recording (but continue to play)
411- MDPlayerStopRecording(player);
414+ if (isAudioRecording)
415+ [myDocument finishAudioRecording];
416+ else
417+ [myDocument finishRecording];
418+ isRecording = NO;
419+ [recordButton setState:NSOffState];
412420 }
413421 }
414- }
422+ // }
415423 }
416- #endif
417424 }
418425 // if (status != kMDPlayer_playing && !(status == kMDPlayer_exhausted && isRecording && !isAudioRecording)) {
419426 // if (status != kMDPlayer_playing && status != kMDPlayer_suspended) {
420- if (status == kMDPlayer_exhausted && !isRecording && !isAudioRecording) {
427+ if (status == kMDPlayer_exhausted && (!isRecording || isAudioRecording)) {
421428 // If not playing, then self stop
422429 [self pressStopButton: self];
423430 }
@@ -596,6 +603,7 @@
596603 return;
597604 }
598605 isRecording = YES;
606+ [recordButton setState:NSOnState];
599607 } else
600608 MDPlayerStart(player);
601609
@@ -688,6 +696,7 @@
688696 [myDocument finishRecording];
689697 isRecording = NO;
690698 isAudioRecording = NO;
699+ [recordButton setState:NSOnState];
691700 }
692701 MDPlayerStop(player);
693702 /* MDPlayerRefreshTrackDestinations(player); *//* Refresh internal track list */
--- trunk/Classes/MyMIDISequence.m (revision 26)
+++ trunk/Classes/MyMIDISequence.m (revision 27)
@@ -408,10 +408,10 @@
408408 tick = (MDTickType)[[recordingInfo valueForKey: MyRecordingInfoStartTickKey] doubleValue];
409409 if (tick >= 0 && tick < kMDMaxTick)
410410 MDPlayerJumpToTick(myPlayer, tick);
411- if ([[recordingInfo valueForKey: MyRecordingInfoStopFlagKey] boolValue]) {
411+/* if ([[recordingInfo valueForKey: MyRecordingInfoStopFlagKey] boolValue]) {
412412 tick = (MDTickType)[[recordingInfo valueForKey: MyRecordingInfoStopTickKey] doubleValue];
413413 MDPlayerScheduleStopTick(myPlayer, tick);
414- }
414+ } */
415415 MDPlayerStartRecording(myPlayer);
416416 return kMDNoError;
417417 }
@@ -546,10 +546,10 @@
546546
547547 /* #error "Maybe need to set up audio thru device here" */
548548
549- if ([[recordingInfo valueForKey: MyRecordingInfoStopFlagKey] boolValue]) {
549+/* if ([[recordingInfo valueForKey: MyRecordingInfoStopFlagKey] boolValue]) {
550550 tick = (MDTickType)[[recordingInfo valueForKey: MyRecordingInfoStopTickKey] doubleValue];
551551 MDPlayerScheduleStopTick(myPlayer, tick);
552- }
552+ } */
553553
554554 MDPlayerStart(myPlayer);
555555 MDAudioStartRecording();
--- trunk/MD_package/MDPlayer_MacOSX.c (revision 26)
+++ trunk/MD_package/MDPlayer_MacOSX.c (revision 27)
@@ -1023,7 +1023,7 @@
10231023 if (nextTick > now_tick)
10241024 break; /* Should be processed in the next interrupt cycle */
10251025 code = MDGetCode(ep);
1026- if (code == kMDSpecialEndOfSequence || code == kMDSpecialStopPlaying) {
1026+ if ((code == kMDSpecialEndOfSequence && !inPlayer->isRecording) || code == kMDSpecialStopPlaying) {
10271027 if (inPlayer->isRecording)
10281028 MDPlayerStopRecording(inPlayer);
10291029 if (MDAudioIsRecording())
@@ -1136,13 +1136,15 @@
11361136 /* Ring metronome */
11371137 if (gMetronomeInfo.enableWhenPlay || (gMetronomeInfo.enableWhenRecord && inPlayer->isRecording)) {
11381138 int isPrincipal = 0;
1139+ MDTickType metTick;
1140+ MDTimeType metTime;
11391141 if (inPlayer->nextMetronomeBeat < 0) {
11401142 PrepareMetronomeForTick(inPlayer, now_tick);
11411143 }
1142- while (inPlayer->nextMetronomeBeat < nextTick) {
1144+ while (inPlayer->nextMetronomeBeat < prefetch_tick) {
11431145 if (inPlayer->nextMetronomeBeat >= inPlayer->nextMetronomeBar) {
11441146 /* Ring the bell */
1145- nextTick = inPlayer->nextMetronomeBar;
1147+ metTick = inPlayer->nextMetronomeBar;
11461148 isPrincipal = 1;
11471149 if (inPlayer->nextMetronomeBar == inPlayer->nextTimeSignature) {
11481150 /* Update the new beat/bar */
@@ -1169,17 +1171,18 @@
11691171 inPlayer->nextMetronomeBar = inPlayer->nextTimeSignature;
11701172 } else {
11711173 /* Ring the click */
1172- nextTick = inPlayer->nextMetronomeBeat;
1174+ metTick = inPlayer->nextMetronomeBeat;
11731175 isPrincipal = 0;
11741176 inPlayer->nextMetronomeBeat += inPlayer->metronomeBeat;
11751177 }
11761178 if (inPlayer->nextMetronomeBeat > inPlayer->nextMetronomeBar)
11771179 inPlayer->nextMetronomeBeat = inPlayer->nextMetronomeBar;
1178- nextTime = MDCalibratorTickToTime(inPlayer->calib, nextTick);
1179- MDPlayerRingMetronomeClick(inPlayer, nextTime, isPrincipal);
1180+ metTime = MDCalibratorTickToTime(inPlayer->calib, metTick);
1181+ MDPlayerRingMetronomeClick(inPlayer, metTime, isPrincipal);
11801182 }
1183+ nextTick = inPlayer->nextMetronomeBeat;
11811184 } else inPlayer->nextMetronomeBeat = -1; /* Disable internal information */
1182-
1185+
11831186 *outNextTick = nextTick;
11841187 return bytesSent;
11851188 }
@@ -1212,7 +1215,7 @@
12121215 }
12131216
12141217 player->time = now_time;
1215- if (tick >= kMDMaxTick || player->status == kMDPlayer_exhausted) {
1218+ if (tick >= kMDMaxTick || (player->status == kMDPlayer_exhausted && !player->isRecording)) {
12161219 player->status = kMDPlayer_exhausted;
12171220 // player->time = MDCalibratorTickToTime(player->calib, MDSequenceGetDuration(MDMergerGetSequence(player->merger)));
12181221 if (tick >= kMDMaxTick)
@@ -1696,16 +1699,14 @@
16961699 MDTickType tick, duration;
16971700 duration = MDSequenceGetDuration(sequence);
16981701 MDSetKind(&anEvent, kMDEventSpecial);
1699- if (inPlayer->stopTick < kMDMaxTick) {
1700- MDSetCode(&anEvent, kMDSpecialStopPlaying);
1701- MDSetTick(&anEvent, inPlayer->stopTick);
1702- RegisterEventInNoteOffTrack(inPlayer, &anEvent);
1703- }
1704- if (inPlayer->isRecording)
1705- tick = kMDMaxTick - 1; /* Don't stop at the end of sequence */
1706- else tick = duration;
1702+ if (inPlayer->stopTick < kMDMaxTick)
1703+ tick = inPlayer->stopTick;
1704+ else tick = kMDMaxTick - 1;
1705+ MDSetCode(&anEvent, kMDSpecialStopPlaying);
1706+ MDSetTick(&anEvent, inPlayer->stopTick);
1707+ RegisterEventInNoteOffTrack(inPlayer, &anEvent);
17071708 MDSetCode(&anEvent, kMDSpecialEndOfSequence);
1708- MDSetTick(&anEvent, tick);
1709+ MDSetTick(&anEvent, duration);
17091710 RegisterEventInNoteOffTrack(inPlayer, &anEvent);
17101711 }
17111712
--- trunk/MD_package/MDAudio_MacOSX.c (revision 26)
+++ trunk/MD_package/MDAudio_MacOSX.c (revision 27)
@@ -1208,6 +1208,9 @@
12081208 int scope;
12091209 if (idx >= 0 && idx < kMDAudioNumberOfInputStreams) {
12101210 scope = kAudioUnitScope_Input;
1211+ } else if (idx >= kMDAudioFirstIndexForOutputStream && idx < kMDAudioNumberOfStreams) {
1212+ idx -= kMDAudioFirstIndexForOutputStream;
1213+ scope = kAudioUnitScope_Output;
12111214 } else return kMDErrorCannotSetupAudio;
12121215 CHECK_ERR(err, AudioUnitSetParameter(gAudio->mixerUnit, kStereoMixerParam_Pan, scope, idx, f32, 0));
12131216 return kMDNoError;
Show on old repository browser