mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Track tempo while playing
This commit is contained in:
parent
0a71cc8cae
commit
b68fc2dd5a
|
@ -53,6 +53,7 @@ enum {
|
||||||
PDFDocument * printDoc;
|
PDFDocument * printDoc;
|
||||||
NSRange previewRange;
|
NSRange previewRange;
|
||||||
float playRate;
|
float playRate;
|
||||||
|
float baseTempo;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (VLSong *) song;
|
- (VLSong *) song;
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
songArranger = @"";
|
songArranger = @"";
|
||||||
songGroove = @"Swing";
|
songGroove = @"Swing";
|
||||||
songTempo = [[NSNumber alloc] initWithInt:120];
|
songTempo = [[NSNumber alloc] initWithInt:120];
|
||||||
|
baseTempo = 120.0f;
|
||||||
chordSize = 6.0f;
|
chordSize = 6.0f;
|
||||||
lyricSize = 0.0f;
|
lyricSize = 0.0f;
|
||||||
staffSize = 20.0f;
|
staffSize = 20.0f;
|
||||||
|
@ -266,6 +267,16 @@
|
||||||
[self didChangeSong];
|
[self didChangeSong];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setSongTempo:(int)tempo
|
||||||
|
{
|
||||||
|
[self willChangeSong];
|
||||||
|
[songTempo autorelease];
|
||||||
|
songTempo = [[NSNumber numberWithInt:tempo] retain];
|
||||||
|
if (VLSoundOut::Instance()->Playing())
|
||||||
|
VLSoundOut::Instance()->SetPlayRate(playRate*tempo/baseTempo);
|
||||||
|
[self didChangeSong];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setGroove:(NSString *)groove inSections:(NSRange)sections
|
- (void) setGroove:(NSString *)groove inSections:(NSRange)sections
|
||||||
{
|
{
|
||||||
const char * grv = [groove UTF8String];
|
const char * grv = [groove UTF8String];
|
||||||
|
@ -525,6 +536,8 @@
|
||||||
|
|
||||||
hasMusicSequence = true;
|
hasMusicSequence = true;
|
||||||
[sheetWin willPlaySequence:music];
|
[sheetWin willPlaySequence:music];
|
||||||
|
baseTempo = [songTempo floatValue];
|
||||||
|
VLSoundOut::Instance()->SetPlayRate(playRate);
|
||||||
VLSoundOut::Instance()->PlaySequence(music);
|
VLSoundOut::Instance()->PlaySequence(music);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,6 +582,7 @@
|
||||||
const float kUpScale = 1.1f;
|
const float kUpScale = 1.1f;
|
||||||
const float kDownScale = 1.0f/kUpScale;
|
const float kDownScale = 1.0f/kUpScale;
|
||||||
bool nowPlaying = VLSoundOut::Instance()->Playing();
|
bool nowPlaying = VLSoundOut::Instance()->Playing();
|
||||||
|
const float tempoRate = [songTempo floatValue] / baseTempo;
|
||||||
switch (int tag = [sender tag]) {
|
switch (int tag = [sender tag]) {
|
||||||
case 0: // Play
|
case 0: // Play
|
||||||
VLSoundOut::Instance()->SetPlayRate(playRate = 1.0f);
|
VLSoundOut::Instance()->SetPlayRate(playRate = 1.0f);
|
||||||
|
@ -587,7 +601,7 @@
|
||||||
playRate *= kUpScale;
|
playRate *= kUpScale;
|
||||||
else
|
else
|
||||||
playRate *= kDownScale;
|
playRate *= kDownScale;
|
||||||
VLSoundOut::Instance()->SetPlayRate(playRate);
|
VLSoundOut::Instance()->SetPlayRate(playRate*tempoRate);
|
||||||
break;
|
break;
|
||||||
case -2: // To Start
|
case -2: // To Start
|
||||||
VLSoundOut::Instance()->SetTime(0);
|
VLSoundOut::Instance()->SetTime(0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user