summaryrefslogtreecommitdiffhomepage
path: root/examples/audio_raw_stream.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2016-12-25 01:58:56 +0100
committerraysan5 <[email protected]>2016-12-25 01:58:56 +0100
commit5de597579feff50ab63ba4285984b64473241c46 (patch)
treed32d299bbdf39f3317d59482d3269f0c3988fbc2 /examples/audio_raw_stream.c
parent4419ee9802d7a45929fb4ecae2163d12fb44f2a7 (diff)
downloadraylib-5de597579feff50ab63ba4285984b64473241c46.tar.gz
raylib-5de597579feff50ab63ba4285984b64473241c46.zip
Complete review of audio module
Diffstat (limited to 'examples/audio_raw_stream.c')
-rw-r--r--examples/audio_raw_stream.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/examples/audio_raw_stream.c b/examples/audio_raw_stream.c
index c044a7e0..d1fd1794 100644
--- a/examples/audio_raw_stream.c
+++ b/examples/audio_raw_stream.c
@@ -16,7 +16,7 @@
#include <stdlib.h> // Required for: malloc(), free()
#include <math.h> // Required for: sinf()
-#define MAX_SAMPLES 20000
+#define MAX_SAMPLES 22050
int main()
{
@@ -29,15 +29,15 @@ int main()
InitAudioDevice(); // Initialize audio device
- // Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
- AudioStream stream = InitAudioStream(22050, 32, 1);
+ // Init raw audio stream (sample rate: 22050, sample size: 16bit-short, channels: 1-mono)
+ AudioStream stream = InitAudioStream(22050, 16, 1);
// Fill audio stream with some samples (sine wave)
- float *data = (float *)malloc(sizeof(float)*MAX_SAMPLES);
+ short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
for (int i = 0; i < MAX_SAMPLES; i++)
{
- data[i] = sinf(((2*PI*(float)i)/2)*DEG2RAD);
+ data[i] = (short)(sinf(((2*PI*(float)i)/2)*DEG2RAD)*32000);
}
// NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
@@ -87,7 +87,7 @@ int main()
for (int i = 0; i < GetScreenWidth(); i++)
{
position.x = i;
- position.y = 250 + 50*data[i];
+ position.y = 250 + 50*data[i]/32000;
DrawPixelV(position, RED);
}