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