Inter-App-Communication: WWDC?

65 views
Skip to first unread message

nlogmusic (TempoRubato - NLogSynth)

unread,
May 15, 2012, 8:05:20 PM5/15/12
to open-music-app...@googlegroups.com
Hi,

we all know that there's no first level inter-app communication support in iOS. Gruber has put it recently on his fanboy blog:

===
"What else remains hanging low on the iOS new-features tree, though? I can think of a few:

Clever inter-application communication. Seems crazy that iOS, the direct descendant of NeXT, doesn’t have anything like Services, which were one of NeXT’s most touted features (and rightfully so). It’s also worth noting that Android has a pretty good Services-esque system in place, called “Intents”, and Windows 8 has an even richer concept called “Contracts”."


I wouldn't wonder if Apple presents something in this regard at WWDC. Would be nice if anybody attending could check this out and post something in case.

Best
Rolf

PS: And I fully agree in regards to NeXT and its services. Apple tried to put it into OSX as well, but they didn't get it rocking.




rrr00bb

unread,
May 19, 2012, 9:13:54 AM5/19/12
to Open Music App Collaboration
Hello guys! I think I am very close to being able to do an audio copy
out of my app and have GarageBand recognize it. The copy from my app
happens without indicent. It causes paste to become available from
GarageBand. But then, I get "Unsupported file format" "The pasted
audio data uses an unsupported file format". GarageBand supports
uncompressed audio files with 44.1khz sample rate and 16-bit depth."
So that is exactly what I am doing. I must have the format wrong.
Can anybody see anything glaringly wrong in this code (that implements
the audioCopyWrite functions by casting to the appropriate type and
assigning... not sure if there are endian problems in flags, etc.)

I implement this file format as best as I can tell:

http://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CAFSpec/CAF_overview/CAF_overview.html#//apple_ref/doc/uid/TP40001862-CH209-TPXREF101

If I paste a string of bits and note that it's audio, the format being
wrong seems to be the only thing it could be. (I also noted that
there doesn't seem to be any kind of end-of-stream marker, that it
uses buffer size to figure that out...doesn't seem right because you
need to be able to parse these as they pass through a data pipe.).
Anyways... here:

void audioCopy()
{
UIPasteboard *board = [UIPasteboard generalPasteboard];

// Write the straight loop in
int cursor=0;
NSLog(@"writing CAF format to UIPasteboard");
NSLog(@"writing type,version,flags");
//Type,Version,Flags
audioCopyWrite32(copyBuffer8,&cursor,'caff'); //type of file
(magic)
audioCopyWrite16(copyBuffer8,&cursor,1); //version
audioCopyWrite16(copyBuffer8,&cursor,0); //flags
//Chunk header, type, len
audioCopyWrite32(copyBuffer8,&cursor,'desc'); //description header
follows
audioCopyWrite64(copyBuffer8,&cursor,32); //32 to bytes
required for it
//Description
audioCopyWrite64(copyBuffer8,&cursor,44100); //rate
audioCopyWrite32(copyBuffer8,&cursor,'lpcm'); //format
audioCopyWrite32(copyBuffer8,&cursor,0); //flags -- little
endian
audioCopyWrite32(copyBuffer8,&cursor,4); //bytes per packet
audioCopyWrite32(copyBuffer8,&cursor,1); //frames per packet
audioCopyWrite32(copyBuffer8,&cursor,2); //channels
audioCopyWrite32(copyBuffer8,&cursor,16); //bits per channel

NSLog(@"writing dataheader");
audioCopyWrite32(copyBuffer8,&cursor,'data'); //data follows
audioCopyWrite64(copyBuffer8,&cursor,loop.size*4); //4 bytes per
stereo sample

NSLog(@"writing stereo 16bit 44.1hz stereo data of length
%d",loop.size);
for(int i=0; i<loop.size; i++)
{
//Is left or right first? It will matter when I get paste to
work on GB
int16_t sampleL = floatToSample16(loopBufferL[i +
loop.firstOffset + loop.secondOffset]);
int16_t sampleR = floatToSample16(loopBufferR[i +
loop.firstOffset + loop.secondOffset]);
audioCopyWrite16(copyBuffer8,&cursor,sampleL);
audioCopyWrite16(copyBuffer8,&cursor,sampleR);
}

//This actually causes Garage Band to try.. formatting just seems
wrong
NSLog(@"copy data to pasteboard");
NSData *dataFile = [NSData dataWithBytes:copyBuffer8
length:cursor];
[board setData:dataFile forPasteboardType:
(NSString*)kUTTypeAudio];
}
Reply all
Reply to author
Forward
0 new messages