diff --git a/Backends/Kinc-hxcpp/lib/khalib/loader.c b/Backends/Kinc-hxcpp/lib/khalib/loader.c index 7a7026e3a..cfd317aa6 100644 --- a/Backends/Kinc-hxcpp/lib/khalib/loader.c +++ b/Backends/Kinc-hxcpp/lib/khalib/loader.c @@ -104,10 +104,9 @@ static void run(void *param) { next.data.sound.samples[i * 2 + 0] = (float)(sound->left[i] / 32767.0); next.data.sound.samples[i * 2 + 1] = (float)(sound->right[i] / 32767.0); } - next.data.sound.channels = sound->format.channels; - next.data.sound.sample_rate = sound->format.samples_per_second; - next.data.sound.length = - (sound->size / (sound->format.bits_per_sample / 8) / sound->format.channels) / (float)sound->format.samples_per_second; + next.data.sound.channels = sound->channel_count; + next.data.sound.sample_rate = sound->samples_per_second; + next.data.sound.length = (sound->size / (sound->bits_per_sample / 8) / sound->channel_count) / (float)sound->samples_per_second; kinc_a1_sound_destroy(sound); } else { diff --git a/Backends/Kinc-hxcpp/main.cpp b/Backends/Kinc-hxcpp/main.cpp index f4a0c8777..55e340feb 100644 --- a/Backends/Kinc-hxcpp/main.cpp +++ b/Backends/Kinc-hxcpp/main.cpp @@ -202,7 +202,7 @@ namespace { #endif bool mixThreadregistered = false; - void mix(kinc_a2_buffer_t *buffer, int samples, void *userdata) { + void mix(kinc_a2_buffer_t *buffer, uint32_t samples, void *userdata) { using namespace Kore; int t0 = 99; @@ -226,7 +226,7 @@ namespace { } #endif - ::kha::audio2::Audio_obj::_callCallback(samples, buffer->format.samples_per_second); + ::kha::audio2::Audio_obj::_callCallback(samples * 2, kinc_a2_samples_per_second()); #ifdef KORE_MULTITHREADED_AUDIO if (mixThreadregistered) { @@ -236,8 +236,10 @@ namespace { for (int i = 0; i < samples; ++i) { float value = ::kha::audio2::Audio_obj::_readSample(); - *(float *)&buffer->data[buffer->write_location] = value; - buffer->write_location += 4; + buffer->channels[0][buffer->write_location] = value; + value = ::kha::audio2::Audio_obj::_readSample(); + buffer->channels[1][buffer->write_location] = value; + buffer->write_location += 1; if (buffer->write_location >= buffer->data_size) { buffer->write_location = 0; } @@ -342,7 +344,7 @@ void post_kinc_init() { void kha_kinc_init_audio(void) { kinc_a2_set_callback(mix, nullptr); kinc_a2_init(); - ::kha::audio2::Audio_obj::samplesPerSecond = kinc_a2_samples_per_second; + ::kha::audio2::Audio_obj::samplesPerSecond = kinc_a2_samples_per_second(); } void run_kinc() { diff --git a/Kinc b/Kinc index 83af1a742..fe440b430 160000 --- a/Kinc +++ b/Kinc @@ -1 +1 @@ -Subproject commit 83af1a7421465c4d904ba31c8ba6433e2c35d65f +Subproject commit fe440b430b1932efc3f622b2252613f8961d5252