Implement Stop/Restart

This commit is contained in:
Matthias Neeracher 2008-07-05 13:56:51 +00:00
parent 4ba648dcd8
commit c8e8a6eb4f
4 changed files with 44 additions and 36 deletions

View File

@ -45,6 +45,7 @@ enum {
NSMutableDictionary*validTmpFiles;
int repeatVolta;
bool brandNew;
bool hasMusicSequence;
VLSheetWindow * sheetWin;
VLLogWindow * logWin;
VLPDFWindow * pdfWin;

View File

@ -91,6 +91,7 @@
vcsWrapper = nil;
repeatVolta = 2;
brandNew = true;
hasMusicSequence = false;
playRate = 1.0;
observers = [[NSMutableArray alloc] init];
validTmpFiles = [[NSMutableDictionary alloc] initWithCapacity:10];
@ -112,6 +113,7 @@
- (void)updateChangeCount:(NSDocumentChangeType)changeType
{
hasMusicSequence = true;
[validTmpFiles removeAllObjects];
[super updateChangeCount:changeType];
}
@ -495,6 +497,9 @@
- (IBAction) play:(id)sender
{
if (hasMusicSequence) {
VLSoundOut::Instance()->PlaySequence(NULL);
} else {
[self createTmpFileWithExtension:@"mid" ofType:@"VLMIDIType"];
MusicSequence music;
@ -517,8 +522,10 @@
VLMIDIWriter annotate(music, countIn);
annotate.Visit(*song);
hasMusicSequence = true;
[sheetWin willPlaySequence:music];
VLSoundOut::Instance()->PlaySequence(music);
}
}
- (void) playWithGroove:(NSString *)groove inSections:(NSRange)sections

View File

@ -27,7 +27,7 @@ public:
virtual void PlayNote(const VLNote & note);
virtual void PlayChord(const VLChord & chord);
virtual void PlaySequence(MusicSequence music);
virtual void Stop();
virtual void Stop(bool pause);
virtual bool Playing();
virtual void SetPlayRate(float rate);
virtual void SetTime(MusicTimeStamp time);
@ -125,7 +125,7 @@ VLAUSoundOut::VLAUSoundOut(bool)
VLAUSoundOut::~VLAUSoundOut()
{
DisposeMusicPlayer(fPlayer);
Stop();
Stop(false);
DisposeAUGraph(fGraph);
}
@ -189,13 +189,15 @@ void VLAUSoundOut::SetupOutput(AUNode)
void VLAUSoundOut::PlaySequence(MusicSequence music)
{
Stop();
if (music) {
Stop(false);
fMusic = music;
fMusicLength = SequenceLength(music);
R(MusicSequenceSetAUGraph(fMusic, fGraph));
R(MusicPlayerSetSequence(fPlayer, fMusic));
}
R(MusicPlayerStart(fPlayer));
fRunning = true;
@ -220,17 +222,15 @@ void VLAUSoundOut::SetTime(MusicTimeStamp time)
MusicPlayerSetTime(fPlayer, time);
}
void VLAUSoundOut::Stop()
void VLAUSoundOut::Stop(bool pause)
{
MusicPlayerStop(fPlayer);
if (fRunning) {
fRunning = false;
if (fMusic) {
if (!pause && fMusic) {
MusicPlayerSetSequence(fPlayer, NULL);
DisposeMusicSequence(fMusic);
fMusic = 0;
}
}
}
bool VLAUSoundOut::Playing()

View File

@ -39,7 +39,7 @@ public:
virtual void PlayChord(const VLChord & chord) = 0;
void PlayFile(CFDataRef file);
virtual void PlaySequence(MusicSequence music) = 0;
virtual void Stop() = 0;
virtual void Stop(bool pause=true) = 0;
virtual bool Playing() = 0;
virtual void SetPlayRate(float rate) = 0;
virtual void SetTime(MusicTimeStamp time) = 0;