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

View File

@ -77,6 +77,7 @@
songArranger = @""; songArranger = @"";
songGroove = @"Swing"; songGroove = @"Swing";
songTempo = [[NSNumber numberWithInt:120] retain]; songTempo = [[NSNumber numberWithInt:120] retain];
playElements = kVLPlayAccompaniment|kVLPlayMelody|kVLPlayCountIn;
sheetWin = nil; sheetWin = nil;
pdfWin = nil; pdfWin = nil;
logWin = nil; logWin = nil;
@ -249,6 +250,21 @@
return repeatVolta; 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 - (bool) brandNew
{ {
return brandNew && ![self isDocumentEdited]; return brandNew && ![self isDocumentEdited];
@ -435,6 +451,17 @@
VLSoundOut::Instance()->Stop(); 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 - (IBAction) showOutput:(id)sender
{ {
[self createTmpFileWithExtension:@"pdf" ofType:@"VLPDFType"]; [self createTmpFileWithExtension:@"pdf" ofType:@"VLPDFType"];

View File

@ -29,10 +29,27 @@
+ "Solo Volume fff\n"; + "Solo Volume fff\n";
sprintf(buf, "Tempo %d\n", [songTempo intValue]); sprintf(buf, "Tempo %d\n", [songTempo intValue]);
mmaFile += buf; 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]); sprintf(buf, "Groove %s\n", [songGroove UTF8String]);
mmaFile += buf; mmaFile += buf;
sprintf(buf, "KeySig %d%c\n", labs(prop.fKey), prop.fKey>=0 ? '#' : '&'); sprintf(buf, "KeySig %d%c\n", labs(prop.fKey), prop.fKey>=0 ? '#' : '&');
mmaFile += buf; mmaFile += buf;
if (!(playElements & kVLPlayAccompaniment))
mmaFile += "AllTracks Off\nSolo On\n";
if (!(playElements & kVLPlayMelody))
mmaFile += "Solo Off\n";
mmaFile += '\n'+writer.Measures(); mmaFile += '\n'+writer.Measures();
return [[NSString stringWithUTF8String:mmaFile.c_str()] return [[NSString stringWithUTF8String:mmaFile.c_str()]

View File

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

View File

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

10
TODO
View File

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