Skip to content

Audio in cutscenes #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DETHRACE/pc-win95/win95sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ void Win32CreateWindow(void) {

int width = gGraf_specs[gGraf_spec_index].total_width;
int height = gGraf_specs[gGraf_spec_index].total_height;
// WS_VISIBLE | WS_POPUP
gWin32_hwnd = CreateWindowExA_(0, "CarmageddonClass", "Carmageddon", 0x90000000, 0, 0, width, height, 0, NULL, NULL, NULL);
int dwStyle = 0x90000000; // WS_VISIBLE | WS_POPUP
gWin32_hwnd = CreateWindowExA_(0, "CarmageddonClass", "Carmageddon", dwStyle, 0, 0, width, height, 0, NULL, NULL, NULL);
SSDXGetWindowRect(gWin32_hwnd);
// hdc = GetDC(gWin32_hwnd);
// GetSystemPaletteEntries(hdc, 0, 256u, &gWin32_palette);
Expand Down
8 changes: 3 additions & 5 deletions src/S3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
add_library(s3 STATIC)

target_include_directories(s3
target_include_directories(s3
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include"
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(s3 PRIVATE brender SDL2::SDL2 harness miniaudio compile_with_werror)
target_link_libraries(s3 PRIVATE brender SDL2::SDL2 harness compile_with_werror)

if(NOT MSVC)
target_link_libraries(s3 PUBLIC pthread m)
Expand Down Expand Up @@ -48,6 +48,4 @@ target_sources(s3 PRIVATE
s3music.h
s3sound.c
s3sound.h
backends/miniaudio_backend.c
backends/backend.h
)
4 changes: 2 additions & 2 deletions src/S3/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "resource.h"

#include "3d.h"
#include "backends/backend.h"
#include "harness/audio.h"
#include "harness/config.h"
#include "harness/os.h"
#include "harness/trace.h"
Expand Down Expand Up @@ -835,7 +835,7 @@ void S3ServiceOutlets(void) {

int S3ServiceChannel(tS3_channel* chan) {
if (chan->type == eS3_ST_sample) {
if (AudioBackend_SoundIsPlaying(chan)) {
if (AudioBackend_SoundIsPlaying(chan->type_struct_sample)) {
return 1;
}
S3StopSample(chan);
Expand Down
26 changes: 0 additions & 26 deletions src/S3/backends/backend.h

This file was deleted.

150 changes: 0 additions & 150 deletions src/S3/backends/miniaudio_backend.c

This file was deleted.

1 change: 0 additions & 1 deletion src/S3/s3_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "s3/s3.h"

#include <miniaudio/miniaudio.h>
#include <stdint.h>

// extern int PDGetTotalTime();
Expand Down
31 changes: 22 additions & 9 deletions src/S3/s3sound.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "s3sound.h"
#include "audio.h"
#include "backends/backend.h"
#include "harness/audio.h"
#include "harness/hooks.h"
#include "harness/trace.h"
#include "resource.h"
Expand Down Expand Up @@ -259,7 +259,7 @@ int S3StopSample(tS3_channel* chan) {
return 0;
}

AudioBackend_StopSample(chan);
AudioBackend_StopSample(chan->type_struct_sample);

if (chan->active) {
chan->needs_service = 1;
Expand All @@ -280,6 +280,7 @@ int S3ExecuteSampleFilterFuncs(tS3_channel* chan) {
}

int S3PlaySample(tS3_channel* chan) {
tS3_sample* sound_data;

if (chan->type_struct_sample == NULL) {
return 0;
Expand All @@ -288,7 +289,14 @@ int S3PlaySample(tS3_channel* chan) {
S3SyncSampleVolumeAndPan(chan);
S3SyncSampleRate(chan);

if (AudioBackend_PlaySample(chan) != eAB_success) {
sound_data = (tS3_sample*)chan->descriptor->sound_data;
if (AudioBackend_PlaySample(chan->type_struct_sample,
sound_data->channels,
sound_data->dataptr,
sound_data->size,
sound_data->rate,
chan->repetitions == 0)
!= eAB_success) {
return 0;
}
// if (chan->descriptor && chan->descriptor->type == chan->type) {
Expand Down Expand Up @@ -359,7 +367,7 @@ int S3SyncSampleVolumeAndPan(tS3_channel* chan) {
volume_db = 0;
}

if (AudioBackend_SetVolume(chan, volume_db) == eAB_success && chan->spatial_sound) {
if (AudioBackend_SetVolume(chan->type_struct_sample, volume_db) == eAB_success && chan->spatial_sound) {

if (chan->left_volume != 0 && chan->right_volume > chan->left_volume) {
pan_ratio = chan->right_volume / (float)chan->left_volume;
Expand All @@ -375,24 +383,29 @@ int S3SyncSampleVolumeAndPan(tS3_channel* chan) {
} else {
pan = 10000;
}
AudioBackend_SetPan(chan, pan);
AudioBackend_SetPan(chan->type_struct_sample, pan);
}
}
return 1;
}

int S3SyncSampleRate(tS3_channel* chan) {
int new_rate;
tS3_sample* sound_data;

if (chan->type != eS3_ST_sample) {
return 1;
}

int rate = chan->rate;
if (rate >= 100000) {
rate = 100000;
new_rate = chan->rate;
if (new_rate >= 100000) {
new_rate = 100000;
}

sound_data = (tS3_sample*)chan->descriptor->sound_data;

// sound_buffer->lpVtbl->SetFrequency(sound_buffer, rate);
AudioBackend_SetFrequency(chan, rate);
AudioBackend_SetFrequency(chan->type_struct_sample, sound_data->rate, new_rate);

return 1;
}
Expand Down
16 changes: 4 additions & 12 deletions src/harness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ target_include_directories(harness
PRIVATE
.
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/DETHRACE
"${CMAKE_CURRENT_BINARY_DIR}"
PUBLIC
include
Expand All @@ -20,11 +19,7 @@ if(DETHRACE_FIX_BUGS)
target_compile_definitions(harness PRIVATE DETHRACE_FIX_BUGS)
endif()

target_link_libraries(harness PRIVATE brender s3 compile_with_werror)

if(WIN32)
target_link_libraries(harness PRIVATE dbghelp)
endif()
target_link_libraries(harness PRIVATE brender miniaudio compile_with_werror)

if(NOT MSVC)
target_compile_options(harness PRIVATE
Expand Down Expand Up @@ -53,14 +48,14 @@ target_sources(harness PRIVATE
include/harness/os.h
include/harness/win95_polyfill.h
include/harness/win95_polyfill_defs.h
include/harness/audio.h
# cameras/debug_camera.c
# cameras/debug_camera.h
ascii_tables.h
harness_trace.c
harness.c
harness.h
sound/sound.c
sound/sound.h
audio/miniaudio.c
win95/polyfill.c
win95/winsock.c
platforms/null.c
Expand All @@ -70,21 +65,18 @@ target_sources(harness PRIVATE
)

if (IO_PLATFORM STREQUAL "SDL2")

target_sources(harness PRIVATE
platforms/sdl2.c
platforms/sdl2_scancode_to_dinput.h

)
target_include_directories(harness PRIVATE "${dethrace_SOURCE_DIR}/src/DETHRACE/common")
target_link_libraries(harness PRIVATE SDL2::SDL2)
endif()

if(WIN32)
target_sources(harness PRIVATE
os/windows.c
)
target_link_libraries(harness PRIVATE ws2_32)
target_link_libraries(harness PRIVATE dbghelp ws2_32)
elseif(APPLE)
target_sources(harness PRIVATE
os/macos.c
Expand Down
Loading