fixed sound stere in the sokol demo
This commit is contained in:
parent
10cc0bb9a9
commit
ca2deef8c6
|
@ -1 +1 @@
|
|||
Subproject commit f4349bec5a48b3a1261a10888edccd15aa649c4f
|
||||
Subproject commit 215169c035212fe09b1f31006c25fd180da98323
|
|
@ -250,13 +250,13 @@ else()
|
|||
set(SOKOL_SRC ${SOKOL_SRC} ${EXAMPLE_DIR}/sokol/sokol.c)
|
||||
endif()
|
||||
|
||||
add_executable(sokol ${SOKOL_SRC})
|
||||
add_executable(sokol-renderer ${SOKOL_SRC})
|
||||
|
||||
if(APPLE)
|
||||
set_property (TARGET sokol APPEND_STRING PROPERTY
|
||||
set_property (TARGET sokol-renderer APPEND_STRING PROPERTY
|
||||
COMPILE_FLAGS "-fobjc-arc")
|
||||
|
||||
target_link_libraries(sokol
|
||||
target_link_libraries(sokol-renderer
|
||||
"-framework Cocoa"
|
||||
"-framework QuartzCore"
|
||||
"-framework Metal"
|
||||
|
@ -265,19 +265,19 @@ if(APPLE)
|
|||
)
|
||||
elseif(LINUX)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
|
||||
target_link_libraries(sokol X11 GL m dl asound)
|
||||
target_link_libraries(sokol-renderer X11 GL m dl asound)
|
||||
endif()
|
||||
|
||||
target_include_directories(sokol PRIVATE include)
|
||||
target_include_directories(sokol PRIVATE 3rd-party/sokol)
|
||||
target_include_directories(sokol PRIVATE src)
|
||||
target_include_directories(sokol-renderer PRIVATE include)
|
||||
target_include_directories(sokol-renderer PRIVATE 3rd-party/sokol)
|
||||
target_include_directories(sokol-renderer PRIVATE src)
|
||||
|
||||
if(MINGW)
|
||||
target_link_libraries(sokol mingw32)
|
||||
target_link_libraries(sokol-renderer mingw32)
|
||||
endif()
|
||||
|
||||
add_dependencies(sokol tic80core)
|
||||
target_link_libraries(sokol tic80core)
|
||||
add_dependencies(sokol-renderer tic80core)
|
||||
target_link_libraries(sokol-renderer tic80core)
|
||||
|
||||
################################
|
||||
# SDL GPU
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <tic80.h>
|
||||
|
||||
static tic80* tic = NULL;
|
||||
|
@ -254,7 +256,7 @@ void gfx_draw() {
|
|||
static void app_init(void)
|
||||
{
|
||||
saudio_desc desc = {0};
|
||||
|
||||
desc.num_channels = 2;
|
||||
saudio_setup(&desc);
|
||||
|
||||
FILE* file = fopen("cart.tic", "rb");
|
||||
|
@ -294,14 +296,10 @@ static void app_frame(void)
|
|||
|
||||
gfx_draw();
|
||||
|
||||
// TODO: Sokol doesn't support stereo at the moment
|
||||
// will fix it later
|
||||
enum {Channels = 1};
|
||||
static float floatSamples[44100 / 60 * 2];
|
||||
|
||||
static float floatSamples[44100/60 * Channels];
|
||||
|
||||
for(s32 i = 0; i < tic->sound.count; i+=2)
|
||||
floatSamples[i>>1] = (float)(tic->sound.samples[i] + tic->sound.samples[i+1]) / 65536.0f;
|
||||
for(s32 i = 0; i < tic->sound.count; i++)
|
||||
floatSamples[i] = (float)tic->sound.samples[i] / SHRT_MAX;
|
||||
|
||||
saudio_push(floatSamples, tic->sound.count / 2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue