2006-11-04 08:15:34 +00:00
|
|
|
|
//
|
2007-04-27 06:41:34 +00:00
|
|
|
|
// File: VLMMADocument.mm - Export document in MMA format
|
2006-11-04 08:15:34 +00:00
|
|
|
|
//
|
2007-04-27 06:41:34 +00:00
|
|
|
|
// Author(s):
|
|
|
|
|
//
|
|
|
|
|
// (MN) Matthias Neeracher
|
|
|
|
|
//
|
2011-07-24 03:32:13 +00:00
|
|
|
|
// Copyright <20> 2006-2007 Matthias Neeracher
|
2006-11-04 08:15:34 +00:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "VLMMADocument.h"
|
2007-05-27 04:35:45 +00:00
|
|
|
|
#import "VLMMAWriter.h"
|
2006-11-04 08:15:34 +00:00
|
|
|
|
|
|
|
|
|
@implementation VLDocument (MMA)
|
|
|
|
|
|
|
|
|
|
- (NSData *)mmaDataWithError:(NSError **)outError
|
|
|
|
|
{
|
2008-01-24 01:29:18 +00:00
|
|
|
|
char buf[32];
|
|
|
|
|
NSBundle * bndl = [NSBundle mainBundle];
|
|
|
|
|
VLMMAWriter writer(playElements & kVLPlayGroovePreview,
|
|
|
|
|
previewRange.location,
|
|
|
|
|
previewRange.location+previewRange.length);
|
2006-11-04 08:15:34 +00:00
|
|
|
|
|
2008-01-24 01:29:18 +00:00
|
|
|
|
writer.Visit(*song);
|
2006-11-04 08:15:34 +00:00
|
|
|
|
std::string mmaFile = std::string("// Generated by VocalEasel ")
|
|
|
|
|
+ (const char *)[[bndl objectForInfoDictionaryKey:@"CFBundleVersion"]
|
|
|
|
|
UTF8String]
|
2008-01-24 01:29:18 +00:00
|
|
|
|
+ "\n\n";
|
2011-09-04 19:48:57 +00:00
|
|
|
|
sprintf(buf, "Tempo %ld\n", lround(songTempo));
|
2006-11-04 08:15:34 +00:00
|
|
|
|
mmaFile += buf;
|
2008-01-24 01:29:18 +00:00
|
|
|
|
if (playElements & kVLPlayGroovePreview) {
|
|
|
|
|
//
|
|
|
|
|
// Override all other flags
|
|
|
|
|
//
|
|
|
|
|
mmaFile += "Groove ";
|
|
|
|
|
mmaFile += [songGroove UTF8String];
|
|
|
|
|
mmaFile += "\nSolo Off\n";
|
|
|
|
|
} else {
|
|
|
|
|
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;
|
|
|
|
|
}
|
2011-09-04 23:38:01 +00:00
|
|
|
|
mmaFile += "Solo Voice AltoSax\nSolo Volume fff\n";
|
2008-01-24 01:29:18 +00:00
|
|
|
|
}
|
2007-05-27 04:35:45 +00:00
|
|
|
|
mmaFile += '\n'+writer.Measures();
|
2006-11-04 08:15:34 +00:00
|
|
|
|
|
|
|
|
|
return [[NSString stringWithUTF8String:mmaFile.c_str()]
|
|
|
|
|
dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSFileWrapper *)mmaFileWrapperWithError:(NSError **)outError
|
|
|
|
|
{
|
|
|
|
|
NSData * data = [self mmaDataWithError:outError];
|
|
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
|
return nil;
|
|
|
|
|
else
|
|
|
|
|
return [[[NSFileWrapper alloc]
|
|
|
|
|
initRegularFileWithContents:data]
|
|
|
|
|
autorelease];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|