mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 03:04:00 +00:00
Change playElements on the fly
This commit is contained in:
parent
2de587cf2f
commit
bf48c51fbd
|
@ -292,10 +292,17 @@
|
|||
|
||||
- (void)setPlayElements:(int)elements
|
||||
{
|
||||
[self willChangeValueForKey:@"playElements"];
|
||||
playElements = elements;
|
||||
[validTmpFiles removeObjectForKey:@"mma"];
|
||||
[validTmpFiles removeObjectForKey:@"mid"];
|
||||
hasMusicSequence = false;
|
||||
if (!(playElements & (kVLPlayMelody|kVLPlayAccompaniment)))
|
||||
playElements |= kVLPlayAccompaniment;
|
||||
if ((playElements & (kVLPlayMelody|kVLPlayGroovePreview)) != kVLPlayMelody)
|
||||
VLSoundOut::Instance()->SetMelodyState(VLSoundOut::kMelodyMute);
|
||||
else if (!(playElements & (kVLPlayAccompaniment|kVLPlayGroovePreview)))
|
||||
VLSoundOut::Instance()->SetMelodyState(VLSoundOut::kMelodySolo);
|
||||
else
|
||||
VLSoundOut::Instance()->SetMelodyState(VLSoundOut::kMelodyRegular);
|
||||
[self didChangeValueForKey:@"playElements"];
|
||||
}
|
||||
|
||||
- (int) repeatVolta
|
||||
|
@ -476,7 +483,7 @@
|
|||
NewMusicSequence(&music);
|
||||
|
||||
MusicSequenceFileLoad(music, (CFURLRef)[self fileURLWithExtension:@"mid"],
|
||||
0, kMusicSequenceLoadSMF_ChannelsToTracks);
|
||||
0, 0);
|
||||
|
||||
size_t countIn = 0;
|
||||
if (playElements & kVLPlayCountIn)
|
||||
|
@ -495,6 +502,7 @@
|
|||
VLSoundOut::Instance()->SetPlayRate(playRate);
|
||||
VLSoundOut::Instance()->PlaySequence(music);
|
||||
}
|
||||
[self setPlayElements:[self playElements]];
|
||||
}
|
||||
|
||||
- (void) playWithGroove:(NSString *)groove inSections:(NSRange)sections
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
@"!(SELF matches[c] '.*(Intro|End)\\\\d*$')"]
|
||||
retain];
|
||||
fView = view;
|
||||
fSheetWin = (VLSheetWindow *)[view window];
|
||||
fSheetWin = [[view window] windowController];
|
||||
|
||||
[NSApp beginSheet: [self window]
|
||||
modalForWindow: [view window]
|
||||
|
|
|
@ -49,12 +49,7 @@
|
|||
// Can't handle these yet
|
||||
break;
|
||||
}
|
||||
if (!(playElements & kVLPlayAccompaniment))
|
||||
mmaFile += "AllTracks Off\nSolo On\n";
|
||||
if (playElements & kVLPlayMelody)
|
||||
mmaFile += "Solo Voice AltoSax\nSolo Volume fff\n";
|
||||
else
|
||||
mmaFile += "Solo Off\n";
|
||||
}
|
||||
mmaFile += '\n'+writer.Measures();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
}
|
||||
|
||||
- (VLPlaybackEditable *)initWithView:(VLSheetView *)view;
|
||||
- (void) userEvent:(NSValue *)event;
|
||||
- (void) userEvent:(const VLMIDIUserEvent *)event;
|
||||
- (void) highlightCursor;
|
||||
|
||||
@end
|
||||
|
@ -47,9 +47,8 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) userEvent:(NSValue *)ev
|
||||
- (void) userEvent:(const VLMIDIUserEvent *) event
|
||||
{
|
||||
VLMIDIUserEvent * event = (VLMIDIUserEvent *)[ev pointerValue];
|
||||
if (event->fPitch) {
|
||||
fNoteMeasure = event->fMeasure;
|
||||
fNoteAt = event->fAt;
|
||||
|
@ -103,9 +102,9 @@ VLSequenceCallback(
|
|||
MusicTimeStamp inEventTime, const MusicEventUserData *inEventData,
|
||||
MusicTimeStamp inStartSliceBeat, MusicTimeStamp inEndSliceBeat)
|
||||
{
|
||||
[(id)inClientData performSelectorOnMainThread:@selector(userEvent:)
|
||||
withObject:[NSValue valueWithPointer:inEventData]
|
||||
waitUntilDone:NO];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(id)inClientData userEvent:(const VLMIDIUserEvent *)inEventData];
|
||||
});
|
||||
}
|
||||
|
||||
@implementation VLSheetView (Selection)
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
virtual void SetPlayRate(float rate);
|
||||
virtual void Fwd();
|
||||
virtual void Bck();
|
||||
virtual void SetMelodyState(MelodyState state);
|
||||
|
||||
virtual ~VLAUSoundOut();
|
||||
void PollMusic();
|
||||
|
@ -67,6 +68,7 @@ public:
|
|||
protected:
|
||||
virtual void SetupOutput(AUNode outputNode);
|
||||
virtual void PlaySequence(MusicSequence music);
|
||||
virtual void SetMelodyState(MelodyState state) {}
|
||||
private:
|
||||
AudioUnit fOutput;
|
||||
CFURLRef fFile;
|
||||
|
@ -111,8 +113,7 @@ void VLSoundOut::PlayFile(CFDataRef file)
|
|||
MusicSequence music;
|
||||
|
||||
NewMusicSequence(&music);
|
||||
MusicSequenceFileLoadData(music, file, 0,
|
||||
kMusicSequenceLoadSMF_ChannelsToTracks);
|
||||
MusicSequenceFileLoadData(music, file, 0, 0);
|
||||
PlaySequence(music);
|
||||
}
|
||||
|
||||
|
@ -222,6 +223,21 @@ void VLAUSoundOut::PlaySequence(MusicSequence music)
|
|||
dispatch_source_set_timer(fMusicPoll, DISPATCH_TIME_NOW, 500*NSEC_PER_MSEC, 200*NSEC_PER_MSEC);
|
||||
}
|
||||
|
||||
void VLAUSoundOut::SetMelodyState(VLSoundOut::MelodyState state)
|
||||
{
|
||||
if (fMusic) {
|
||||
UInt32 numTracks;
|
||||
MusicTrack curTrack;
|
||||
MusicSequenceGetTrackCount(fMusic, &numTracks);
|
||||
MusicSequenceGetIndTrack(fMusic, numTracks-2, &curTrack);
|
||||
|
||||
Boolean mute = state==kMelodyMute;
|
||||
Boolean solo = state==kMelodySolo;
|
||||
|
||||
MusicTrackSetProperty(curTrack, kSequenceTrackProperty_MuteStatus, &mute, sizeof(mute));
|
||||
MusicTrackSetProperty(curTrack, kSequenceTrackProperty_SoloStatus, &solo, sizeof(solo));
|
||||
}
|
||||
}
|
||||
void VLAUSoundOut::SetPlayRate(float rate)
|
||||
{
|
||||
if ((rate < 0) != fForward) {
|
||||
|
|
|
@ -48,6 +48,12 @@ public:
|
|||
virtual void SetPlayRate(float rate) = 0;
|
||||
virtual void Fwd() = 0;
|
||||
virtual void Bck() = 0;
|
||||
enum MelodyState {
|
||||
kMelodyMute,
|
||||
kMelodyRegular,
|
||||
kMelodySolo
|
||||
};
|
||||
virtual void SetMelodyState(MelodyState state) = 0;
|
||||
|
||||
virtual ~VLSoundOut();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user