TonicAudio / Tonic

Easy and efficient audio synthesis in C++
The Unlicense
522 stars 63 forks source link

Issues on Linux #188

Closed ndonald2 closed 11 years ago

ndonald2 commented 11 years ago

Stemming from the discussion with @anhinga about synthesis output issues in Linux.

Moving the discussion here so we have a more permanent record to look back at if we need to.

The Issue

However, the pure sine wave, Generator output = SineWave().freq(300.0);, is still silent, and this is what it prints:

-0.987133 -0.987133 -0.987133 -0.987133 -0.987134 -0.987134 -0.987134 -0.987134 -0.987134 -0.987134 -0.987134 -0.987134

that's at saturation...

starts with all zeros,  then -0.504508 -0.504508 -0.508191 -0.508191 -0.511876 -0.511876 -0.515562 -0.515562 -0.51925 -0.51925 -0.522939 -
0.522939 -0.52663 -0.52663 -0.530322 -0.530322 -0.534016 -0.534016 -0.537711 -0.537711 -0.541408 -0.541408 -0
.545107 -0.545107 -0.548807 -0.548807 ... -0.653201 -0.654057 -0.654057 -0.654909 -0.654909 -0.655757 -0.655757 -0.656601 -0.656601 -0.65744 -0.65744
 -0.658275 -0.658275,

then -0.739352 -0.739352 -0.739825 -0.739825 -0.740297 -0.740297 -0.740766 -0.740766 -0.741234 -0.741234 -0.7417 -
0.7417 -0.742165 -0.742165 -0.742628 -0.742628 -0.743089 -0.743089 -0.743548 -0.743548 -0.744005 -0.744005 -0
.744461 -0.744461 -0.744915 ...

generated by the following lines in renderCallback:

    cout << "\n**********************\n";
    for (unsigned int debug_i = 0; debug_i < nBufferFrames; debug_i++) {
        cout << ((float*)outputBuffer)[debug_i] << " ";
    }
    cout << "\n======================\n";

Reproducibility

I was not able to reproduce the issue on a fresh, vanilla Ubuntu 12.04 installation (using ALSA). When I build and run the demo I hear the correct sound, which leads me to believe it is a difference in hardware or the build environment.

ndonald2 commented 11 years ago

Turned out to be an issue with 64-bit integer lengths. Fixed in the ND-Linux branch, pending updates to the build configuration.