diff options
| author | raysan5 <raysan5@gmail.com> | 2016-12-25 01:58:56 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-12-25 01:58:56 +0100 |
| commit | 5de597579feff50ab63ba4285984b64473241c46 (patch) | |
| tree | d32d299bbdf39f3317d59482d3269f0c3988fbc2 /examples | |
| parent | 4419ee9802d7a45929fb4ecae2163d12fb44f2a7 (diff) | |
| download | raylib-5de597579feff50ab63ba4285984b64473241c46.tar.gz raylib-5de597579feff50ab63ba4285984b64473241c46.zip | |
Complete review of audio module
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/audio_module_playing.c | 2 | ||||
| -rw-r--r-- | examples/audio_music_stream.c | 2 | ||||
| -rw-r--r-- | examples/audio_raw_stream.c | 12 |
3 files changed, 8 insertions, 8 deletions
diff --git a/examples/audio_module_playing.c b/examples/audio_module_playing.c index 4582a561..08ae2b05 100644 --- a/examples/audio_module_playing.c +++ b/examples/audio_module_playing.c @@ -86,7 +86,7 @@ int main() } // Get timePlayed scaled to bar dimensions - timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2; + timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40); // Color circles animation for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--) diff --git a/examples/audio_music_stream.c b/examples/audio_music_stream.c index dc9d4355..9c1ca4df 100644 --- a/examples/audio_music_stream.c +++ b/examples/audio_music_stream.c @@ -58,7 +58,7 @@ int main() } // Get timePlayed scaled to bar dimensions (400 pixels) - timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4; + timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*400; //---------------------------------------------------------------------------------- // Draw 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); } |
