src/rfxgen.c
// Draw wave data
// NOTE: For proper visualization, MSAA x4 is recommended, alternatively
// it should be rendered to a bigger texture and then scaled down with
// bilinear/trilinear texture filtering
Draw wave data
NOTE: For proper visualization, MSAA x4 is recommended, alternatively
it should be rendered to a bigger texture and then scaled down with
bilinear/trilinear texture filtering
Draw wave data NOTE : For proper visualization MSAA x4 is recommended alternatively it should be rendered to a bigger texture and then scaled down with bilinear / trilinear texture filtering
static void DrawWave(Wave *wave, Rectangle bounds, Color color)
{
    float sample, sampleNext;
    float currentSample = 0.0f;
    float sampleIncrement = (float)wave->sampleCount/(float)(bounds.width*2);
    float sampleScale = (float)bounds.height;
    for (int i = 1; i < bounds.width*2 - 1; i++)
    {
        sample = ((float *)wave->data)[(int)currentSample]*sampleScale;
        sampleNext = ((float *)wave->data)[(int)(currentSample + sampleIncrement)]*sampleScale;
        if (sample > bounds.height/2) sample = bounds.height/2;
        else if (sample < -bounds.height/2) sample = -bounds.height/2;
        if (sampleNext > bounds.height/2) sampleNext = bounds.height/2;
        else if (sampleNext < -bounds.height/2) sampleNext = -bounds.height/2;
        DrawLineV((Vector2){ (float)bounds.x + (float)i/2.0f, (float)(bounds.y + bounds.height/2) + sample },
                  (Vector2){ (float)bounds.x + (float)i/2.0f, (float)(bounds.y  + bounds.height/2) + sampleNext }, color);
        currentSample += sampleIncrement;
    }
}
static void DrawWave ( Wave * wave , Rectangle bounds , Color color ) { float sample , sampleNext ; float currentSample = 0.0f ; float sampleIncrement = ( float ) wave -> sampleCount / ( float ) ( bounds . width * 2 ) ; float sampleScale = ( float ) bounds . height ; for ( int i = 1 ; i < bounds . width * 2 - 1 ; i ++ ) { sample = ( ( float * ) wave -> data ) [ ( int ) currentSample ] * sampleScale ; sampleNext = ( ( float * ) wave -> data ) [ ( int ) ( currentSample + sampleIncrement ) ] * sampleScale ; if ( sample > bounds . height / 2 ) sample = bounds . height / 2 ; else if ( sample < - bounds . height / 2 ) sample = - bounds . height / 2 ; if ( sampleNext > bounds . height / 2 ) sampleNext = bounds . height / 2 ; else if ( sampleNext < - bounds . height / 2 ) sampleNext = - bounds . height / 2 ; DrawLineV ( ( Vector2 ) { ( float ) bounds . x + ( float ) i / 2.0f , ( float ) ( bounds . y + bounds . height / 2 ) + sample } , ( Vector2 ) { ( float ) bounds . x + ( float ) i / 2.0f , ( float ) ( bounds . y + bounds . height / 2 ) + sampleNext } , color ) ; currentSample += sampleIncrement ; } }
Draw wave data
NOTE: For proper visualization, MSAA x4 is recommended, alternatively
it should be rendered to a bigger texture and then scaled down with
bilinear/trilinear texture filtering
Draw wave data NOTE : For proper visualization MSAA x4 is recommended alternatively it should be rendered to a bigger texture and then scaled down with bilinear / trilinear texture filtering