Can the Finch library play sounds from NSData sources so that things recorded within the app using AVAudioRecorder can then be played back?
Asked
Active
Viewed 335 times
1 Answers
1
Yes. The FISound
class has an initializer that takes an FISample
, which is just a simple wrapper around NSData
. That means you can stuff your data into an FISample
instance, fill in the audio metadata and use the sample to create an FISound
.

zoul
- 102,279
- 44
- 260
- 354
-
It should be pretty obvious. What did you try, what didn’t work? – zoul Dec 21 '11 at 14:43
-
I see now that there is an NSData property on FISample and so I don't even need to go through the FIDecoder. I was thinking we had to use the FIDecoder to get all of the other properties out. I'll give it a shot now and write back. – Philippe Sabourin Dec 21 '11 at 15:11
-
I'm trying to figure out how to play a sound from a certain time instead of from the start. Is that possible in OpenAL? – Philippe Sabourin Dec 21 '11 at 15:34
-
The [OpenAL Programming Guide](http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf) (PDF) mentions source properties called `AL_SEC_OFFSET`, `AL_SAMPLE_OFFSET`, and `AL_BYTE_OFFSET`. It looks like it should be possible to implement seeking using those, see the gain or pitch setting in Finch for code samples. I might add the feature to Finch, but can’t promise you when that would be. – zoul Dec 21 '11 at 16:29
-
This is what I tried: http://tinypaste.com/904d9f71 and i get: Failed to start sound, error code a003. – Philippe Sabourin Dec 21 '11 at 16:30
-
That looks fine (you’re missing duration, but that should not prevent the sound from playing). Did you initialize Finch? From the OpenAL Guide linked above it looks like `alSourcePlay` may fail if the source is invalid or when there is no current OpenAL context. – zoul Dec 21 '11 at 16:37
-
I initialized finch. I think your FISound init would fail otherwise. I double checked that the data is there and it plays back in AVAudioPlayer correctly. Looks like the a003 code is AL_INVALID_VALUE an invalid value was passed to an OpenAL function – Philippe Sabourin Dec 21 '11 at 16:42
-
I’m not sure how the move-to-chat feature works, but I have moved the discussion to a [chat room](http://chat.stackoverflow.com/rooms/6043). – zoul Dec 21 '11 at 16:54