From d3d9aaceb12111ebe54f55f23cd87dfb43964f1f Mon Sep 17 00:00:00 2001
From: raysan5 <raysan5@gmail.com>
Date: Wed, 3 Aug 2016 09:26:30 +0200
Subject: [PATCH] Updated and comments

---
 examples/audio_raw_stream.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/examples/audio_raw_stream.c b/examples/audio_raw_stream.c
index 37a5b4ff..a372205b 100644
--- a/examples/audio_raw_stream.c
+++ b/examples/audio_raw_stream.c
@@ -16,6 +16,8 @@
 #include <stdlib.h>         // Required for: malloc(), free()
 #include <math.h>           // Required for: sinf()
 
+#define MAX_SAMPLES      20000
+
 int main()
 {
     // Initialization
@@ -28,19 +30,23 @@ int main()
 
     InitAudioDevice();              // Initialize audio device
 
-    AudioStream stream = InitAudioStream(44100, 32, 1);  // Init raw audio stream
+    // Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
+    AudioStream stream = InitAudioStream(22050, 32, 1);
     
     // Fill audio stream with some samples (sine wave)
-    float *data = (float *)malloc(sizeof(float)*44100);
+    float *data = (float *)malloc(sizeof(float)*MAX_SAMPLES);
     
-    for (int i = 0; i < 44100; i++)
+    for (int i = 0; i < MAX_SAMPLES; i++)
     {
-        data[i] = sinf(2*PI*(float)i*DEG2RAD);
+        data[i] = sinf(((2*PI*(float)i)/2)*DEG2RAD);
     }
     
+    // NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop
+    // for that reason, there is a clip everytime audio stream is looped
+    
     PlayAudioStream(stream);
     
-    int totalSamples = 44100;
+    int totalSamples = MAX_SAMPLES;
     int samplesLeft = totalSamples;
     
     Vector2 position = { 0, 0 };