mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
55 lines
1.3 KiB
Plaintext
55 lines
1.3 KiB
Plaintext
//
|
|
// File: VLMMADocument.mm - Export document in MMA format
|
|
//
|
|
// Author(s):
|
|
//
|
|
// (MN) Matthias Neeracher
|
|
//
|
|
// Copyright © 2006-2007 Matthias Neeracher
|
|
//
|
|
|
|
#import "VLMMADocument.h"
|
|
#import "VLMMAWriter.h"
|
|
|
|
@implementation VLDocument (MMA)
|
|
|
|
- (NSData *)mmaDataWithError:(NSError **)outError
|
|
{
|
|
char buf[32];
|
|
NSBundle * bndl = [NSBundle mainBundle];
|
|
VLMMAWriter writer;
|
|
writer.Visit(*song);
|
|
const VLProperties & prop = song->fProperties.front();
|
|
|
|
std::string mmaFile = std::string("// Generated by VocalEasel ")
|
|
+ (const char *)[[bndl objectForInfoDictionaryKey:@"CFBundleVersion"]
|
|
UTF8String]
|
|
+ "\n\n"
|
|
+ "Solo Voice AltoSax\n"
|
|
+ "Solo Volume fff\n";
|
|
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'+writer.Measures();
|
|
|
|
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
|