Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project.xcworkspace
xcuserdata

51 changes: 51 additions & 0 deletions CfxrDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "CfxrDocument.h"
#import "Sound.h"
#import "Sound+legacyAccessors.h"
#import "Playback.h"

NSString *CfxrSoundPBoardType = @"CfxrSoundPBoardType";
Expand Down Expand Up @@ -187,6 +188,56 @@ - (IBAction) copy:(id) sender
[generalPasteboard setData:copyData forType:CfxrSoundPBoardType];
[generalPasteboard setString:[copyStringsArray componentsJoinedByString:@"\n"] forType:NSStringPboardType];
}

// Special copy variant, builds string in format ready for usfxr
// See https://github.com/zeh/usfxr
- (IBAction)copyForUsfxr:(id)sender
{
NSArray *selectedObjects = [soundsController selectedObjects];
NSUInteger count = [selectedObjects count];
if (count == 0) return;

NSMutableArray *copyObjectsArray = [NSMutableArray arrayWithCapacity:count];
NSMutableArray *copyStringsArray = [NSMutableArray arrayWithCapacity:count];

for (Sound *s in selectedObjects)
{
[copyObjectsArray addObject:[s dictionaryRepresentation]];
NSString *description = [NSString stringWithFormat:@"%d,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
s.wave_type,
s.p_env_attack,
s.p_env_sustain,
s.p_env_punch,
s.p_env_decay,
s.p_base_freq,
s.p_freq_limit,
s.p_freq_ramp,
s.p_freq_dramp,
s.p_vib_strength,
s.p_vib_speed,
s.p_arp_mod,
s.p_arp_speed,
s.p_duty,
s.p_duty_ramp,
s.p_repeat_speed,
s.p_pha_offset,
s.p_pha_ramp,
s.p_lpf_freq,
s.p_lpf_ramp,
s.p_lpf_resonance,
s.p_hpf_freq,
s.p_hpf_ramp,
s.sound_vol];
[copyStringsArray addObject:description];
}

NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard];
[generalPasteboard declareTypes:[NSArray arrayWithObjects:CfxrSoundPBoardType, NSStringPboardType, nil] owner:self];
NSData *copyData = [NSKeyedArchiver archivedDataWithRootObject:copyObjectsArray];
[generalPasteboard setData:copyData forType:CfxrSoundPBoardType];
[generalPasteboard setString:[copyStringsArray componentsJoinedByString:@"\n"] forType:NSStringPboardType];
}

- (IBAction) paste:(id) sender
{
NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard];
Expand Down
Loading