Re: OS X NSPasteBoard and Wave data
Re: OS X NSPasteBoard and Wave data
- Subject: Re: OS X NSPasteBoard and Wave data
- From: Kyle Sluder <email@hidden>
- Date: Wed, 09 Apr 2014 23:31:28 -0700
On Wed, Apr 9, 2014, at 09:00 PM, Charles Constant wrote:
> Hello all,
>
> Does anyone have some tips on sending PCM audio to the clipboard, for use
> with other apps?
>
> I'd like to be able to paste to as many other apps as possible, ideally
> without writing a file to disk. I've done a little research, and there
> doesn't seem to be any current standard to do so. This is my first large
> project using Cocoa/Objective C so I'm feeling a bit overwhelmed.
>
> I'm currently creating a wav file in memory, passing it to create an
> instance of an NSSound, and putting that in NSPasteboard's
> generalPasteboard. I gather NSSound is rather limited though (I've read
> you
> can't even get at the samples, just use [sound play]???). And QTKit...
> deprecated (I see QTP7 wraps its clipboard audio in a movie).
I can't tell how much experience you have with Cocoa and the
NSPasteboard APIs, particularly the new ones.
When you write data to a pasteboard, you give the pasteboard a UTI
(Uniform Type Identifier) that describes the kind of data. AVFoundation,
being the modern replacement for QTKit, declares a number of symbols for
audiovisual data UTIs in AVMediaFormat.h.
Here's the simplest way I'd write WAV sound data:
// warning: code untested; written in Mail
NSData *myWavData = /* ... */;
NSPasteboardItem *pbItem = [NSPasteboardItem new];
[pbItem setData:myWavData forType:AVFileTypeWAVE];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
[pboard clearContents];
BOOL ok = [pboard writeObjects:@[pbItem]];
// handle failure if ! ok
> Maybe this is not worth the effort? I have a half dozen audio apps on my
> hard drive, and I can't seem to find anything other than Quicktime Pro 7
> that can handle clipboard audio from anything else :(
GarageBand doesn't? Huh.
--Kyle Sluder
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden