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
|
|
|
|
//
|
|
|
|
// Copyright © 2006-2007 Matthias Neeracher
|
2006-11-04 08:15:34 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "VLMMADocument.h"
|
|
|
|
|
|
|
|
@implementation VLDocument (MMA)
|
|
|
|
|
|
|
|
- (NSData *)mmaDataWithError:(NSError **)outError
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
NSBundle * bndl = [NSBundle mainBundle];
|
|
|
|
const VLProperties & prop = song->fProperties.front();
|
|
|
|
|
|
|
|
std::string mmaFile = std::string("// Generated by VocalEasel ")
|
|
|
|
+ (const char *)[[bndl objectForInfoDictionaryKey:@"CFBundleVersion"]
|
|
|
|
UTF8String]
|
2007-01-02 07:07:39 +00:00
|
|
|
+ "\n\n"
|
|
|
|
+ "Solo Voice AltoSax\n"
|
|
|
|
+ "Solo Volume fff\n";
|
2006-11-04 08:15:34 +00:00
|
|
|
sprintf(buf, "Tempo %d\n", [songTempo intValue]);
|
|
|
|
mmaFile += buf;
|
|
|
|
sprintf(buf, "Groove %s\n", [songGroove UTF8String]);
|
|
|
|
mmaFile += buf;
|
|
|
|
sprintf(buf, "KeySig %d%c\n", labs(prop.fKey), prop.fKey>=0 ? '#' : '&');
|
|
|
|
mmaFile += buf;
|
|
|
|
mmaFile += '\n';
|
|
|
|
|
|
|
|
std::string mmas;
|
2006-12-31 10:31:29 +00:00
|
|
|
size_t meas = 0;
|
|
|
|
VLSong::iterator end = song->end();
|
|
|
|
for (VLSong::iterator i=song->begin(); i!=end; ++i) {
|
|
|
|
size_t m = *i;
|
|
|
|
sprintf(buf, "%-5d", ++meas);
|
2006-11-04 08:15:34 +00:00
|
|
|
mmaFile += buf;
|
2007-04-23 05:46:37 +00:00
|
|
|
song->fMeasures[m].MMAChords(mmas, prop, i==song->begin());
|
2006-11-04 08:15:34 +00:00
|
|
|
mmaFile += mmas;
|
2007-04-22 06:20:17 +00:00
|
|
|
song->fMeasures[m].MMANotes(mmas, prop, song->TiedDuration(m+1));
|
2006-11-04 08:15:34 +00:00
|
|
|
mmaFile += "\t{ " + mmas + " }\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|