We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 214 - Patch for SDL audio recording
Summary: Patch for SDL audio recording
Status: RESOLVED DUPLICATE of bug 10
Alias: None
Product: SDL
Classification: Unclassified
Component: audio (show other bugs)
Version: 2.0.0
Hardware: All All
: P2 enhancement
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-04 00:39 UTC by Sam Lantinga
Modified: 2006-05-04 00:47 UTC (History)
0 users

See Also:


Attachments
SDL-1.2-record.diff (21.54 KB, patch)
2006-05-04 00:42 UTC, Sam Lantinga
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Lantinga 2006-05-04 00:39:56 UTC
Date: 09 Apr 2002 18:09:25 -0700
From: Dan Helfman
Subject: [SDL] Patch for SDL audio recording

Attached is a patch for audio recording in SDL. The patch is for SDL
1.2.3 but should apply against CVS too (last I checked, anyway). It
retains source compatibility with the SDL 1.2 audio playback API, so all
your old programs should still compile against and work with this
patched SDL (let me know if they don't). It most definitely does not
retain binary compatibility, so I don't expect this patch to make it
into SDL 1.2. I'm hoping that some sort of recording ability will make
it into 1.3.

Because I tried to retain source compatibility with the current API, I
could not make the most elegant modifications possible, and indeed the
patch is rather hackish and currently only works for DSP audio.

Here's how you use it in your programs. With standard SDL audio playing,
you setup a callback in your audio spec that is called whenever SDL
needs a chunk of audio to fill its playback buffer. What I did was add a
second callback (callback_record) that SDL calls whenever it has a chunk
of recorded data (such as from a microphone) available for you. If you
don't set the recording callback to anything, then SDL will behave
exactly as the unpatched SDL with playback-only capabilities. But if
there is a callback_record function, then /dev/dsp will be opened for
read-write and recording should work. Note that if you don't want to do 
any playback at all, you can choose not to set an audio play callback,  
but still set a recording callback.

Feedback is definitely welcome. I'm particularly interested in people
just trying out the patch and reporting whether it works. I'm currently
working on adding wav file writing support so that you can actually *do*
something with all of the nice recorded audio data you get from this  
patched SDL. I'll post new versions here and possibly put up a web page
for the patch if anyone's interested.

For what it's worth, this patch is Copyright (C) 2002 Jim Henson's     
Creature Shop, and it is of course LGPL.

--
Dan Helfman
Jim Henson's Creature Shop
Comment 1 Sam Lantinga 2006-05-04 00:42:17 UTC
Created attachment 110 [details]
SDL-1.2-record.diff
Comment 2 Sam Lantinga 2006-05-04 00:47:25 UTC
Whoops, didn't see bug #10

*** This bug has been marked as a duplicate of 10 ***