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