From 576dfe66536a309f07fe0672aa59ae4d832bfd70 Mon Sep 17 00:00:00 2001 From: rbdannenberg Date: Fri, 1 Oct 2010 15:26:46 +0000 Subject: [PATCH] Restore Audacity xcode project (undoing accidentally committed OS X 10.6 changes in revision 10695). Fix some midi playback problems. --- lib-src/portmidi/pm_mac/pmmacosxcm.c | 1 - lib-src/portsmf/allegro.cpp | 8 +++--- mac/Audacity.xcodeproj/project.pbxproj | 9 +------ src/AudioIO.cpp | 36 ++++++++++++++------------ 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/lib-src/portmidi/pm_mac/pmmacosxcm.c b/lib-src/portmidi/pm_mac/pmmacosxcm.c index 71ceb40e5..8bddde891 100644 --- a/lib-src/portmidi/pm_mac/pmmacosxcm.c +++ b/lib-src/portmidi/pm_mac/pmmacosxcm.c @@ -475,7 +475,6 @@ send_packet(PmInternal *midi, Byte *message, unsigned int messageLength, midi_macosxcm_type m = (midi_macosxcm_type) midi->descriptor; assert(m); - /* printf("add %d to packet %lx len %d\n", message[0], m->packet, messageLength); */ m->packet = MIDIPacketListAdd(m->packetList, sizeof(m->packetBuffer), m->packet, timestamp, messageLength, message); diff --git a/lib-src/portsmf/allegro.cpp b/lib-src/portsmf/allegro.cpp index 6912e0536..430ab4ca8 100644 --- a/lib-src/portsmf/allegro.cpp +++ b/lib-src/portsmf/allegro.cpp @@ -3434,12 +3434,12 @@ Alg_event_ptr Alg_iterator::next(bool *note_on, void **cookie_ptr, insert(events_ptr, index, false, cookie, offset); } // for both note-ons and updates, insert next event (at index + 1) - index++; - if (index < events_ptr->length() && + // DO NOT INCREMENT index: it must be preserved for request_note_off() + if (index + 1 < events_ptr->length() && (end_time == 0 || // zero means ignore end time // stop iterating when end time is reached - (*events_ptr)[index]->time + offset < end_time)) { - insert(events_ptr, index, true, cookie, offset); + (*events_ptr)[index + 1]->time + offset < end_time)) { + insert(events_ptr, index + 1, true, cookie, offset); } } if (cookie_ptr) *cookie_ptr = cookie; diff --git a/mac/Audacity.xcodeproj/project.pbxproj b/mac/Audacity.xcodeproj/project.pbxproj index b3579dbdd..3730ebcf0 100644 --- a/mac/Audacity.xcodeproj/project.pbxproj +++ b/mac/Audacity.xcodeproj/project.pbxproj @@ -6918,14 +6918,7 @@ isa = PBXProject; buildConfigurationList = 1790ABE409883346008A330A /* Build configuration list for PBXProject "Audacity" */; compatibilityVersion = "Xcode 2.4"; - developmentRegion = English; hasScannedForEncodings = 0; - knownRegions = ( - English, - Japanese, - French, - German, - ); mainGroup = 1790ABE109883346008A330A; productRefGroup = 1790AFB109883B6D008A330A /* Products */; projectDirPath = ""; @@ -8419,7 +8412,7 @@ INFOPLIST_PREPROCESS = YES; KEEP_PRIVATE_EXTERNS = YES; ONLY_LINK_ESSENTIAL_SYMBOLS = YES; - SDKROOT = /Developer/SDKs/MacOSX10.5.sdk; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; TOPLEVEL = ..; WX_CFLAGS = "-I$(WX_PREFIX)/lib/wx/include/mac-unicode-debug-static-$(WX_VER) -I$(WX_PREFIX)/include/wx-$(WX_VER) -D__WXDEBUG__ -D__WXMAC__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DNO_GCC_PRAGMA"; WX_CONFIG = "$(WX_PREFIX)/bin/wx-config"; diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 3cbe0a46c..626efd749 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -1350,8 +1350,8 @@ bool AudioIO::StartPortMidiStream() return false; mMidiLatency = 1; // arbitrary, but small - printf("StartPortMidiStream: mT0 %g mTime %g\n", - gAudioIO->mT0, gAudioIO->mTime); + //printf("StartPortMidiStream: mT0 %g mTime %g\n", + // gAudioIO->mT0, gAudioIO->mTime); /* get midi playback device */ PmDeviceID playbackDevice = Pm_GetDefaultOutputDeviceID(); @@ -1383,11 +1383,11 @@ bool AudioIO::StartPortMidiStream() NULL, mMidiLatency); // DEBUGGING - const PmDeviceInfo *info = Pm_GetDeviceInfo(playbackDevice); - printf("Pm_OpenOutput on %s, return code %d\n", - info->name, mLastPmError); - - fprintf(stderr, "mT0: %f\n", mT0); + //const PmDeviceInfo *info = Pm_GetDeviceInfo(playbackDevice); + //printf("Pm_OpenOutput on %s, return code %d\n", + // info->name, mLastPmError); + + //fprintf(stderr, "mT0: %f\n", mT0); mMidiStreamActive = true; mPauseTime = 0; @@ -2707,11 +2707,11 @@ void AudioIO::OutputEvent() } if (command != -1) { Pm_WriteShort(mMidiStream, timestamp, - Pm_Message((int) (command + channel), + Pm_Message((int) (command + channel), (long) data1, (long) data2)); - printf("Pm_WriteShort %x @ %d\n", - Pm_Message((int) (command + channel), - (long) data1, (long) data2), timestamp); + //printf("Pm_WriteShort %x @ %d\n", + // Pm_Message((int) (command + channel), + // (long) data1, (long) data2), timestamp); } } } @@ -2777,8 +2777,8 @@ void AudioIO::FillMidiBuffers() if (mNumCaptureChannels <= 0) { // no audio callback, so move the time cursor here: double track_time = time - mMidiLoopOffset; - printf("mTime set. mT0 %g Pt_Time() %gs PauseTime %g\n", - mT0, Pt_Time() * 0.001, PauseTime()); + //printf("mTime set. mT0 %g Pt_Time() %gs PauseTime %g\n", + // mT0, Pt_Time() * 0.001, PauseTime()); // Since loop offset is incremented when we fill the // buffer, the cursor tends to jump back to mT0 early. // Therefore, if we are in loop mode, and if mTime < mT0, @@ -2819,10 +2819,13 @@ double AudioIO::PauseTime() PmTimestamp AudioIO::MidiTime() { if (mNumPlaybackChannels > 0) { - // note: the extra 0.0005 is for rounding - return PmTimestamp(1000 * (AudioTime() + 1.0005 - + //printf("AudioIO:MidiTime: PaUtil_GetTime() %g mAudioCallbackOutputTime %g time - outputTime %g\n", + // PaUtil_GetTime(), mAudioCallbackOutputTime, PaUtil_GetTime() - mAudioCallbackOutputTime); + // note: the extra 0.0005 is for rounding. Round down by casting to + // unsigned long, then convert to PmTimeStamp (currently signed) + return (PmTimestamp) ((unsigned long) (1000 * (AudioTime() + 1.0005 - mAudioFramesPerBuffer / mRate + - PaUtil_GetTime() - mAudioCallbackOutputTime)); + PaUtil_GetTime() - mAudioCallbackOutputTime))); } else { return Pt_Time(); } @@ -3048,6 +3051,7 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer, #ifdef EXPERIMENTAL_MIDI_OUT /* GSW: Save timeInfo in case MidiPlayback needs it */ gAudioIO->mAudioCallbackOutputTime = timeInfo->outputBufferDacTime; + // printf("in callback, mAudioCallbackOutputTime %g\n", gAudioIO->mAudioCallbackOutputTime); //DBG gAudioIO->mAudioFramesPerBuffer = framesPerBuffer; if(gAudioIO->IsPaused()) gAudioIO->mNumPauseFrames += framesPerBuffer;