diff --git a/English.lproj/VLDocument.xib b/English.lproj/VLDocument.xib index 0d2bad3..0d21ef9 100644 --- a/English.lproj/VLDocument.xib +++ b/English.lproj/VLDocument.xib @@ -59,7 +59,7 @@ 1886912512 Window NSWindow - + E740CC27-9C7E-4EAB-BF3D-81063362B3D3 @@ -71,7 +71,7 @@ 1 1 - + 090F43F9-8231-43FE-922E-78ACFD149536 @@ -93,14 +93,14 @@ YES 0 - + 15BF1B1C-EB04-4D37-B74C-B24F5776A0AF Progress - + 1292 @@ -123,7 +123,7 @@ YES 0 - + 30E4DC32-DB89-4CFC-9F5D-D2D86BC93115 @@ -145,7 +145,7 @@ YES 0 - + 4D42D89B-0099-40D5-916B-59940F715C41 @@ -167,7 +167,7 @@ YES 0 - + 737868E5-40A9-4B03-B2FD-E67F9EE16B2B @@ -189,7 +189,7 @@ YES 0 - + 77A31E50-1A2C-448A-A34C-424E366D478D @@ -211,7 +211,7 @@ YES 0 - + 889E794D-914E-4969-8960-2CCF7C710455 @@ -233,14 +233,14 @@ YES 0 - + D63103EB-B919-45DD-827C-807BA0DB9509 >> >> - + 268 {{0, 14}, {32, 32}} @@ -250,8 +250,8 @@ _NS:1491 1 YES - - 67239424 + + 67763712 134217728 @@ -260,10 +260,10 @@ 1044 _NS:1491 - + -2042347265 134 - + NSImage fwd @@ -273,7 +273,7 @@ 75 - + {32, 32} @@ -284,14 +284,14 @@ YES 0 - + F5E49E9C-6F16-4D08-9781-4AF5849DD18F << << - + 268 {{0, 14}, {32, 32}} @@ -301,16 +301,16 @@ _NS:1491 -1 YES - - 67239424 + + 67763712 134217728 _NS:1491 - + -2042347265 134 - + NSImage bck @@ -320,7 +320,7 @@ 75 - + {32, 32} @@ -331,7 +331,7 @@ YES 0 - + NSToolbarFlexibleSpaceItem Flexible Space @@ -354,17 +354,17 @@ 1048576 2147483647 - + NSImage NSMenuCheckmark - + NSImage NSMenuMixedState - + NSToolbarPrintItem Print Print @@ -384,7 +384,7 @@ YES 0 - + NSToolbarSpaceItem Space @@ -407,38 +407,38 @@ 1048576 2147483647 - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -491,8 +491,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: @@ -508,8 +508,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1 @@ -522,8 +522,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -533,8 +533,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -255 @@ -545,8 +545,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -511 @@ -557,8 +557,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -767 @@ -569,8 +569,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -1023 @@ -581,8 +581,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -1279 @@ -593,8 +593,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -1535 @@ -606,8 +606,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 257 @@ -618,8 +618,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 513 @@ -630,8 +630,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 769 @@ -642,8 +642,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1025 @@ -654,8 +654,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1281 @@ -666,8 +666,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1537 @@ -680,8 +680,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -691,8 +691,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 255 @@ -705,8 +705,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -716,8 +716,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -1 @@ -728,8 +728,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -257 @@ -740,8 +740,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -513 @@ -752,8 +752,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -769 @@ -764,8 +764,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -1025 @@ -776,8 +776,8 @@ 1048576 2147483647 - - + + _popUpItemAction: -1281 @@ -790,8 +790,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -801,8 +801,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 511 @@ -813,8 +813,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 767 @@ -825,8 +825,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1023 @@ -838,8 +838,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: 1279 @@ -850,8 +850,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1535 @@ -862,8 +862,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1791 @@ -906,8 +906,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: 1028 @@ -925,8 +925,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1544 @@ -937,8 +937,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 772 @@ -949,8 +949,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 3080 @@ -961,8 +961,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 1284 @@ -1004,8 +1004,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: 12 @@ -1022,8 +1022,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 2 @@ -1034,8 +1034,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 3 @@ -1046,8 +1046,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 4 @@ -1058,8 +1058,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 6 @@ -1070,8 +1070,8 @@ 1048576 2147483647 - - + + _popUpItemAction: 8 @@ -1330,8 +1330,8 @@ 1048576 2147483647 1 - - + + _popUpItemAction: 1 @@ -1351,8 +1351,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -1362,8 +1362,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -1373,8 +1373,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -1649,7 +1649,7 @@ 0 - + . @@ -1687,7 +1687,7 @@ NaN - + @@ -2515,8 +2515,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA1048576 2147483647 1 - - + + _popUpItemAction: @@ -2533,8 +2533,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2544,8 +2544,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2555,8 +2555,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2566,8 +2566,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2624,8 +2624,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA1048576 2147483647 1 - - + + _popUpItemAction: @@ -2642,8 +2642,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2653,8 +2653,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2664,8 +2664,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2675,8 +2675,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2750,8 +2750,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA1048576 2147483647 1 - - + + _popUpItemAction: @@ -2767,8 +2767,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2778,8 +2778,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2789,8 +2789,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2800,8 +2800,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2811,8 +2811,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2822,8 +2822,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2833,8 +2833,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -2844,8 +2844,8 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 1048576 2147483647 - - + + _popUpItemAction: @@ -4372,7 +4372,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA printDocument: - + 100503 @@ -4380,7 +4380,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA showLog: - + 100504 @@ -4388,7 +4388,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA zoomIn: - + 100505 @@ -4396,7 +4396,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA zoomOut: - + 100506 @@ -4404,7 +4404,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA showOutput: - + 100508 @@ -4412,7 +4412,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA editDisplayOptions: - + 100510 @@ -4420,7 +4420,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA progressIndicator - + 100513 @@ -4428,7 +4428,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA playStop: - + 100514 @@ -4436,7 +4436,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA playMusic: - + 100515 @@ -4444,7 +4444,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA playMusic: - + 100516 @@ -4474,7 +4474,7 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA - + Sheet Music Window @@ -6003,123 +6003,123 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA 100486 - + - - - - - - - - - - - - + + + + + + + + + + + + 100489 - - + + 100490 - - + + 100491 - - + + 100493 - - + + 100494 - - + + 100495 - - + + 100496 - - + + 100499 - + - + - + 100497 - + - + - + 100498 - - + + 100500 - + - + - + Toolbar Item - >> 100501 - + - + - + 100502 - - + + 100492 - - + + 100509 - - + + 100512 - + - + - + 100511 - - + + @@ -6435,65 +6435,6 @@ AAAAAAAAAAAAAHRleHQAAAAAQ29weXJpZ2h0IEFwcGxlIENvbXB1dGVyLCBJbmMuLCAyMDA1AAAAAA - - IKImageView - - crop: - id - - - crop: - - crop: - id - - - - IBProjectSource - ./Classes/IKImageView.h - - - - NSDocument - - id - id - id - id - id - id - - - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - IBProjectSource - ./Classes/NSDocument.h - - VLDocument NSDocument diff --git a/Sources/VLDocument.mm b/Sources/VLDocument.mm index 85d9847..0e10aac 100644 --- a/Sources/VLDocument.mm +++ b/Sources/VLDocument.mm @@ -598,35 +598,12 @@ - (IBAction) playMusic:(id)sender { - const float kUpScale = 1.41f; - const float kDownScale = 1.0f/kUpScale; - bool nowPlaying = VLSoundOut::Instance()->Playing(); - const float tempoRate = [songTempo floatValue] / baseTempo; switch (int tag = [sender tag]) { - case 0: // Play - VLSoundOut::Instance()->SetPlayRate(playRate = 1.0f); - if (!hasMusicSequence || !nowPlaying) - [self play:sender]; - else if (VLSoundOut::Instance()->AtEnd()) - VLSoundOut::Instance()->SetTime(0); - break; case 1: // Fwd + VLSoundOut::Instance()->Fwd(); + break; case -1: // Rew - if (tag * playRate < 0) - playRate = tag; - else if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) - playRate *= kDownScale; - else - playRate *= kUpScale; - VLSoundOut::Instance()->SetPlayRate(playRate*tempoRate); - break; - case -2: // To Start - if (playRate < 0) - VLSoundOut::Instance()->SetPlayRate(playRate = -playRate); - VLSoundOut::Instance()->SetTime(0); - break; - case 2: // To End - VLSoundOut::Instance()->SetTime(0x7FFFFFFF); + VLSoundOut::Instance()->Bck(); break; } } diff --git a/Sources/VLSoundOut.cpp b/Sources/VLSoundOut.cpp index 92cbefc..c7720ac 100644 --- a/Sources/VLSoundOut.cpp +++ b/Sources/VLSoundOut.cpp @@ -17,8 +17,9 @@ #include #include +#include -#define R(x) if (OSStatus r = (x)) fprintf(stderr, "%s -> %ld\n", #x, r); +#define R(x) if (OSStatus r = (x)) fprintf(stderr, "%s -> %d\n", #x, r); class VLAUSoundOut : public VLSoundOut { public: @@ -31,7 +32,8 @@ public: virtual bool Playing(); virtual bool AtEnd(); virtual void SetPlayRate(float rate); - virtual void SetTime(MusicTimeStamp time); + virtual void Fwd(); + virtual void Bck(); virtual ~VLAUSoundOut(); protected: @@ -40,6 +42,7 @@ protected: void InitSoundOutput(bool fileOutput); virtual void SetupOutput(AUNode outputNode); MusicTimeStamp SequenceLength(MusicSequence music); + void SkipTimeInterval(); AUGraph fGraph; MusicPlayer fPlayer; @@ -217,9 +220,41 @@ void VLAUSoundOut::SetPlayRate(float rate) MusicPlayerSetPlayRateScalar(fPlayer, fabsf(rate)); } -void VLAUSoundOut::SetTime(MusicTimeStamp time) +static MusicTimeStamp sLastSkip = 0.0; +static dispatch_source_t sResetTimer; + +void VLAUSoundOut::SkipTimeInterval() { - MusicPlayerSetTime(fPlayer, time); + MusicTimeStamp time; + MusicPlayerGetTime(fPlayer, &time); + time += sLastSkip; + sLastSkip *= 1.1; + if (!sResetTimer) { + sResetTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); + dispatch_source_set_event_handler(sResetTimer, ^{ + sLastSkip = 0.0; + }); + dispatch_source_set_timer(sResetTimer, DISPATCH_TIME_FOREVER, INT64_MAX, 1000*NSEC_PER_USEC); + dispatch_resume(sResetTimer); + } + dispatch_source_set_timer(sResetTimer, dispatch_time(DISPATCH_TIME_NOW, 500*NSEC_PER_MSEC), + INT64_MAX, 10*NSEC_PER_MSEC); + MusicPlayerSetTime(fPlayer, time); +} + +void VLAUSoundOut::Fwd() +{ + if (sLastSkip <= 0.0) + sLastSkip = 0.1; + SkipTimeInterval(); +} + +void VLAUSoundOut::Bck() +{ + if (sLastSkip >= 0.0) + sLastSkip = -0.1; + SkipTimeInterval(); } void VLAUSoundOut::Stop(bool pause) diff --git a/Sources/VLSoundOut.h b/Sources/VLSoundOut.h index 6f7c7f4..e683cbc 100644 --- a/Sources/VLSoundOut.h +++ b/Sources/VLSoundOut.h @@ -43,7 +43,8 @@ public: virtual bool Playing() = 0; virtual bool AtEnd() = 0; virtual void SetPlayRate(float rate) = 0; - virtual void SetTime(MusicTimeStamp time) = 0; + virtual void Fwd() = 0; + virtual void Bck() = 0; virtual ~VLSoundOut(); };