And the makeAsound() function
void makeAsound() {
// initial instrument definition for testing
//string input = "fm 100 150 am 0 100 square 100:20 square 39 adsr 1:0 1000:0 2000:100 5001:100 6000:-100 8000:0 loop level 1";
//string input = "1000 fm 100 150 am 0 100";
string input = "fm 60 140 { fm 60 140 modulator sinus 200 sinus 10 } sinus 1";
long duration = 600;
uint32_t ech = 48000;
const int BUF_LENGTH = 1024;
//SoundGenerator::play(SoundGenerator::factory("fm 50 150 sinus 440 hook_speed"));
SoundGenerator* g = SoundGenerator::factory(input);
SoundGenerator::play(g);
SoundGenerator::setVolume(0); // Avoid sound clicks at start
SoundGenerator::fade_in(10);
SoundGenerator::setVolume(0); // Avoid sound clicks at start
SoundGenerator::fade_in(10);
const int fade_time=50;
if (duration > fade_time) {
SDL_Delay(duration-fade_time); // Play for ms
SoundGenerator::fade_out(fade_time);
SDL_Delay(fade_time); // Play for 100 ms (while fade out)
} else {
SoundGenerator::fade_out(fade_time);
SDL_Delay(fade_time); // Play for ms (while fading out)
}
SDL_Delay(1000); // Wait till the end of buffer is played (avoid clicks) TODO this is buffer size dependant
}
I sometimes (after disabling Orientation directives in the start qml) get:
eglplatform_wayland.cpp:193: EGLNativeWindowType waylandws_CreateWindow(EGLNativeWindowType, _EGLDisplay*): Assertion
ret >= 0’`