Play individual parts / implement count in for 4/4 and 3/4

This commit is contained in:
Matthias Neeracher 2007-12-03 17:45:56 +00:00
parent 6908273ff2
commit b7b1f96f93
10 changed files with 2988 additions and 2684 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -17,6 +17,13 @@
@class VLLogWindow;
@class PDFDocument;
enum {
kVLPlayAccompaniment = 1,
kVLPlayMelody = 2,
kVLPlayMetronome = 4,
kVLPlayCountIn = 8
};
@interface VLDocument : NSDocument
{
VLSong * song;
@ -27,6 +34,7 @@
NSString * songArranger;
NSString * songGroove;
NSNumber * songTempo;
int playElements;
NSString * tmpPath;
NSFileWrapper * vcsWrapper;
NSMutableArray* observers;
@ -56,6 +64,9 @@
- (IBAction) showLog:(id)sender;
- (IBAction) play:(id)sender;
- (IBAction) stop:(id)sender;
- (IBAction) playStop:(id)sender;
- (IBAction) togglePlayElements:(id)sender;
- (IBAction) playStop:(id)sender;
- (NSString *) tmpPath;
- (NSString *) workPath;

View File

@ -77,6 +77,7 @@
songArranger = @"";
songGroove = @"Swing";
songTempo = [[NSNumber numberWithInt:120] retain];
playElements = kVLPlayAccompaniment|kVLPlayMelody|kVLPlayCountIn;
sheetWin = nil;
pdfWin = nil;
logWin = nil;
@ -249,6 +250,21 @@
return repeatVolta;
}
- (IBAction) togglePlayElements:(id)sender
{
playElements ^= [sender tag];
[validTmpFiles removeObjectForKey:@"mma"];
[validTmpFiles removeObjectForKey:@"mid"];
}
- (BOOL) validateMenuItem:(NSMenuItem *)menuItem
{
if (int tag = [menuItem tag])
[menuItem setState:(playElements & tag) != 0];
return YES;
}
- (bool) brandNew
{
return brandNew && ![self isDocumentEdited];
@ -435,6 +451,17 @@
VLSoundOut::Instance()->Stop();
}
- (IBAction) playStop:(id)sender
{
if (VLSoundOut::Instance()->Playing()) {
[self stop:sender];
[sender setTitle:@"Play"];
} else {
[self play:sender];
[sender setTitle:@"Stop"];
}
}
- (IBAction) showOutput:(id)sender
{
[self createTmpFileWithExtension:@"pdf" ofType:@"VLPDFType"];

View File

@ -29,10 +29,27 @@
+ "Solo Volume fff\n";
sprintf(buf, "Tempo %d\n", [songTempo intValue]);
mmaFile += buf;
if (playElements & kVLPlayCountIn)
switch ([[self songTime] intValue]) {
case 0x404:
mmaFile += "Groove Metronome2-4\nz\nz\n";
break;
case 0x304:
case 0x608:
mmaFile += "Groove Metronome3\nz\nz\n";
break;
default:
// Can't handle these yet
break;
}
sprintf(buf, "Groove %s\n", [songGroove UTF8String]);
mmaFile += buf;
sprintf(buf, "KeySig %d%c\n", labs(prop.fKey), prop.fKey>=0 ? '#' : '&');
mmaFile += buf;
if (!(playElements & kVLPlayAccompaniment))
mmaFile += "AllTracks Off\nSolo On\n";
if (!(playElements & kVLPlayMelody))
mmaFile += "Solo Off\n";
mmaFile += '\n'+writer.Measures();
return [[NSString stringWithUTF8String:mmaFile.c_str()]

View File

@ -29,6 +29,7 @@ public:
virtual void PlayChord(const VLChord & chord);
virtual void PlayFile(CFDataRef file);
virtual void Stop();
virtual bool Playing();
virtual ~VLAUSoundOut();
protected:
@ -200,6 +201,11 @@ void VLAUSoundOut::Stop()
}
}
bool VLAUSoundOut::Playing()
{
return fRunning;
}
void VLAUSoundOut::PlayNote(const VLNote & note)
{
Play(&note.fPitch);

View File

@ -38,6 +38,7 @@ public:
virtual void PlayChord(const VLChord & chord) = 0;
virtual void PlayFile(CFDataRef file) = 0;
virtual void Stop() = 0;
virtual bool Playing() = 0;
virtual ~VLSoundOut();
};

10
TODO
View File

@ -1,5 +1,11 @@
TODO
* Change styles / divisions within song
* Play chords / melody only
* Count-off
* Tweak output
* Flexible line breaking
DONE
* Play chords / melody only [03Dec07]
* Count In (4/4 and 3/4 only) [03Dec07]