<li><a href="#GetAudioStatus">GetAudioStatus </a></li>
<li><a href="#LoadWAV">LoadWAV </a></li>
<li><a href="#FreeWAV">FreeWAV </a></li>
-<li><a href="#AudioCVT">AudioCVT </a></li>
-<li><a href="#BuildAudioCVT">BuildAudioCVT </a></li>
-<li><a href="#ConvertAudio">ConvertAudio </a></li>
+<li><a href="#convert_audio">convert_audio</a></li>
<li><a href="#MixAudio">MixAudio </a></li>
<li><a href="#LockAudio">LockAudio</a></li>
<li><a href="#UnlockAudio">UnlockAudio</a></li>
<p>Frees previously opened WAV data</p>
</div>
-<h2 id="AudioCVT">AudioCVT </h2>
-<div id="AudioCVT_CONTENT">
-<p>Audio Conversion Structure</p>
+<h2 id="convert_audio">convert_audio</h2>
+<div id="convert_audio_CONTENT">
+<pre> SDL::Audio->convert_audio( cvt, data, len )
-</div>
-<h2 id="BuildAudioCVT">BuildAudioCVT </h2>
-<div id="BuildAudioCVT_CONTENT">
-<p>Initializes a SDL_AudioCVT - structure for conversion</p>
-
-</div>
-<h2 id="ConvertAudio">ConvertAudio </h2>
-<div id="ConvertAudio_CONTENT">
+</pre>
<p>Converts audio data to a desired audio format.</p>
+<p><code>convert_audio</code> takes as first parameter <code>cvt</code>, which was previously initialized. Initializing a <code>SDL::AudioCVT</code> is a two step process.
+First of all, the structure must be created via <code>SDL::AudioCVT-</code>build> along with source and destination format parameters. Secondly,
+the <code>data</code> and <code>len</code> fields must be setup. <code>data</code> should point to the audio data buffer beeing source and destination at
+once and <code>len</code> should be set to the buffer length in bytes. Remember, the length of the buffer pointed to by buf should be
+<code>len*len_mult</code> bytes in length.</p>
+<p>Once the <code>SDL::AudioCVT</code> structure is initialized, we can pass it to <code>convert_audio</code>, which will convert the audio data pointed to
+by <code>data</code>. If <code>convert_audio</code> fails <code>undef</code> is returned, otherwise the converted <code>SDL::AudioCVT</code> structure.</p>
+<p>If the conversion completed successfully then the converted audio data can be read from <code>cvt-</code>buf>. The amount of valid, converted,
+audio data in the buffer is equal to <code>cvt-</code>len*cvt->len_ratio>. </p>
+<p>Example:</p>
+<pre> use SDL;
+ use SDL::Audio;
+ use SDL::AudioSpec;
+ use SDL::AudioCVT;
+
+ # Converting some WAV data to hardware format
+
+ my $desired = SDL::AudioSpec->new();
+ my $obtained = SDL::AudioSpec->new();
+
+ # Set desired format
+ $desired->freq(22050);
+ $desired->channels(1);
+ $desired->format(AUDIO_S16);
+ $desired->samples(8192);
+
+ # Open the audio device
+ if( SDL::Audio::open_audio($desired, $obtained) < 0 )
+ {
+ printf( STDERR "Couldn't open audio: %s\n", SDL::get_error() );
+ exit(-1);
+ }
+
+ # Load the test.wav
+ my $wav_ref = SDL::Audio::load_wav('C:/SDL_perl/test/data/sample.wav', $obtained);
+
+ unless( $wav_ref )
+ {
+ printf( STDERR "Could not open sample.wav: %s\n", SDL::get_error() );
+ SDL::Audio::close_audio();
+ exit(-1);
+ }
+
+ my ( $wav_spec, $wav_buf, $wav_len ) = @{$wav_ref};
+
+ # Build AudioCVT
+ my $wav_cvt = SDL::AudioCVT->build( $wav_spec->format, $wav_spec->channels, $wav_spec->freq,
+ $obtained->format, $obtained->channels, $obtained->freq);
+
+ # Check that the convert was built
+ unless( $wav_cvt )
+ {
+ printf( STDERR "Couldn't build converter!\n" );
+ SDL::Audio::close_audio();
+ SDL::Audio::free_wav($wav_buf);
+ }
+
+ # And now we're ready to convert
+ SDL::Audio::convert_audio($wav_cvt, $wav_buf, $wav_len);
+
+ # We can delete to original WAV data now
+ SDL::Audio::free_wav($wav_buf);
+
+</pre>
+<p><strong>TODO</strong>: What to do with it? How to use callback? See http://www.libsdl.org/cgi/docwiki.cgi/SDL_ConvertAudio</p>
</div>
<h2 id="MixAudio">MixAudio </h2>