05.05.2013 Views

Huron & SNAP Documentation

Huron & SNAP Documentation

Huron & SNAP Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

WavePlayer-2 Commands<br />

OTHER SIMULATION TOOLS<br />

The WavePlayer-2 is a <strong>Huron</strong> application that can play .WAV<br />

format audio files. WavePlayer-2 does not use any <strong>Huron</strong> DSP<br />

resources, and it is not constrained to the 2Mb memory limit of<br />

the original WavePlayer application.<br />

The <strong>SNAP</strong>WP2LoadWave function blocks and returns only<br />

after the load has succeeded or failed. The return code reflects<br />

whether WavePlayer-2 was able to successfully load the wave<br />

file. All other WavePlayer-2 functions are non-blocking.<br />

Their return codes indicate whether each command was<br />

successfully sent to the <strong>Huron</strong>.<br />

Valid wave IDs are 1 to 256 inclusive. Valid voice IDs are 1 to<br />

128 inclusive.<br />

The sample code shown below provides an example of how to<br />

control WavePlayer-2 using the <strong>SNAP</strong> API.<br />

if (<strong>SNAP</strong>Connect("127.0.0.1"))<br />

{<br />

/* Load sample.wav as wave 1 */<br />

if (!<strong>SNAP</strong>WP2LoadWave(1, "C:\\wavs\\sample.wav"))<br />

printf("Could not load wave file.\n");<br />

else<br />

{<br />

/* Bind voice 5 to wave 1, outputting on channels 3 and 4 */<br />

long lChans[2] = {3, 4};<br />

<strong>SNAP</strong>WP2BindVoice(1, 5, 2, lChans);<br />

}<br />

/* Start voice 5 playing */<br />

<strong>SNAP</strong>WP2PlayVoice(5);<br />

/* Wait for voice to finish playing */<br />

...<br />

/* Release the voice */<br />

<strong>SNAP</strong>WP2ReleaseVoice(5);<br />

/* Remove the wave */<br />

<strong>SNAP</strong>WP2RemoveWave(1);<br />

}<br />

<strong>SNAP</strong>Disconnect();<br />

HURON TECHNICAL MANUAL PAGE 171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!