Complete review of audio module
This commit is contained in:
parent
4419ee9802
commit
5de597579f
5 changed files with 212 additions and 210 deletions
|
@ -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--)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue