Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preliminary audio support #217

Merged
merged 6 commits into from
Jul 9, 2011
Merged

Preliminary audio support #217

merged 6 commits into from
Jul 9, 2011

Conversation

zarvox
Copy link
Member

@zarvox zarvox commented Apr 14, 2011

This patchset adds support for obtaining the audio core firmware, booting the audio core, and streaming audio from the four microphones. A demonstration is provided in examples/wavrecord.c, which writes each microphone's output to a WAV file.

Since audio can't be supported on Windows without some more libusbemu work, I've made audio support a build-time option (BUILD_AUDIO).

Due to the questionable legality of directly redistributing the audio core firmware, I've added a python script which downloads the latest Xbox360 firmware update from Microsoft and extracts the firmware from that .zip file. The firmware is installed as $PREFIX/share/audios.bin, which is great for people running straight from the source, but we also have people who want to use binary packages. For them (and their heroic packagers), I've added a build option BUILD_REDIST_PACKAGE that provides the fwfetcher.py script, rather than audios.bin (which would probably be illegal to redistribute directly). Packages should include a postinstallation hook to download the firmware and place it in /usr/share/libfreenect/, or something of the sort.

This patch adds more API than it guarantees is correctly implemented; further, timestamps need to be added somewhere, so this API is by no means stable. Relevant declarations are contained in a new header: libfreenect-audio.h.

TODO:

  1. Timestamps
  2. Implement correct usage of audio_out_callback
  3. Implement TLS handshake to unlock noise cancelled stream
  4. Work out what the remaining data represents

This commit supports streaming of audio from the four microphones.
We still need to implement timestamps, user-provided audio (for
cancellation), and firmware upload support.  But if you have already
loaded the firmware (say, with NUIse), this works great.

Due to the way we're handling isochronous transfers in libusbemu, this
will probably not work on Windows yet.

To enable audio, add -DBUILD_AUDIO to your cmake command line or enable
the BUILD_AUDIO option in the cmake gui.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
This commit adds a python script to download and extract the audio firmware.
Since we do not have permission to redistribute the audio firmware itself,
we add a build option (BUILD_REDIST_PACKAGE) to disable adding the firmware
to the install and instead shipping the firmware fetcher program.

Packagers should enable this option and add a postinstallation hook that
downloads and places the firmware in /usr/share/libfreenect/.

Users should leave this option disabled, but should NOT redistribute packages
or firmware.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
This patch separates audio support out into a separate libfreenect-audio.h
header.  It updates the CMake lists to place audio support files (either
fwfetcher.py or audios.bin) in the appropriate install folder, rather
than under $PREFIX/lib.

To support uploading the audio firmware, I added two new calls to our
libusb wrapper - we need bulk transfer support to actually send the
firmware, and we need to count the number of interfaces in the current
configuration to distinguish a device in the bootloader from one which has
already had firmware uploaded.  These calls will need to be implemented
in libusbemu before audio will work on Windows.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
… paths.

The firmware uploader will look for audios.bin in the following locations:
$LIBFREENECT_FIRMWARE_PATH/
./
~/.libfreenect/
/usr/local/share/libfreenect/audios.bin
/usr/share/libfreenect/audios.bin

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
This program should show the audio waveforms that are being received in real time.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
If you enabled BUILD_AUDIO but not BUILD_PYTHON, then nothing ever
included FindPythonInterp, so PYTHON_EXECUTABLE path wouldn't be set,
and fwfetcher.py would be the first argument in the call to download
the firmware.  Since fwfetcher.py is not marked executable, this would
fail.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
zarvox added a commit that referenced this pull request Jul 9, 2011
Preliminary audio support

This patchset adds support for obtaining the audio core firmware, booting the 
audio core, and streaming audio from the four microphones. A demonstration is
provided in examples/wavrecord.c, which writes each microphone's output to a
WAV file.  A viewer is provided in examples/micview.c, which draws the waveforms
of the four microphones to the screen in realtime.

Since audio can't be supported on Windows without a different firmware and driver, 
I've made audio support a build-time option (BUILD_AUDIO).

Due to the questionable legality of directly redistributing the audio core 
firmware, I've added a python script which downloads the latest Xbox360
firmware update from Microsoft and extracts the firmware from that .zip file.
The firmware is installed as $PREFIX/share/audios.bin, which is great for
people running straight from the source, but we also have people who want to
use binary packages. For them (and their heroic packagers), I've added a build
option BUILD_REDIST_PACKAGE that provides the fwfetcher.py script, rather than
audios.bin (which would probably be illegal to redistribute directly). Packages
should include a postinstallation hook to download the firmware and place it in
/usr/share/libfreenect/, or something of the sort.

This patch adds more API than it guarantees is correctly implemented; further, 
timestamps need to be added somewhere, so this API is by no means stable.
Relevant declarations are contained in a new header: libfreenect-audio.h.
@zarvox zarvox merged commit adc507b into OpenKinect:unstable Jul 9, 2011
@thprego
Copy link

thprego commented Sep 2, 2011

Any news on the TODO?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants