diff --git a/docs/lua/examples/audio-test/main.lua b/docs/lua/examples/audio-test/main.lua index ce76bf3b..8bae3477 100644 --- a/docs/lua/examples/audio-test/main.lua +++ b/docs/lua/examples/audio-test/main.lua @@ -1,68 +1,61 @@ -- name: Audio Test --- description: audio shits. +-- description: Testing out the custom audio system -- incompatible: -DEBUG = false -UNST22 = true -- gotta work around unst 22 bugs :( +audioStream = nil; +audioSample = nil; -------------------------------------------------------------------------------- - -handle = 0; -s_handle = 0; - -function on_audio_play(msg) - if(msg == "create") then - handle = load_audio("test.mp3") - - djui_chat_message_create("audio handle:" .. tostring(handle)); +function on_stream_play(msg) + if(msg == "load") then + audioStream = audio_stream_load("music.mp3") + audio_stream_set_looping(audioStream, true) + djui_chat_message_create("audio audioStream:" .. tostring(audioStream)); end if(msg == "play") then - play_audio(handle, true); + audio_stream_play(audioStream, true, 1); djui_chat_message_create("playing audio"); end if(msg == "resume") then - play_audio(handle, false); + audio_stream_play(audioStream, false, 1); djui_chat_message_create("resuming audio"); end if(msg == "pause") then - pause_audio(handle); + audio_stream_pause(audioStream); djui_chat_message_create("pausing audio"); end if(msg == "stop") then - stop_audio(handle); + audio_stream_stop(audioStream); djui_chat_message_create("stopping audio"); end if(msg == "destroy") then - destroy_audio(handle); + audio_stream_destroy(audioStream); djui_chat_message_create("destroyed audio"); end if(msg == "getpos") then - djui_chat_message_create("pos: " .. tostring(get_position_audio(handle))); + djui_chat_message_create("pos: " .. tostring(audio_stream_get_position(audioStream))); end return true; end function on_sample_play(msg) - if(msg == "create") then - s_handle = load_sample("test.mp3"); + if(msg == "load") then + audioSample = audio_sample_load("sample.mp3"); - djui_chat_message_create("audio handle:" .. tostring(s_handle)); + djui_chat_message_create("audio audioStream:" .. tostring(audioSample)); return true; end - handle2 = get_audio_from_sample(s_handle); - - play_audio(handle2, false); + audio_sample_play(audioSample, gMarioStates[0].pos, 1); return true; end -hook_chat_command('audio', "options and shit", on_audio_play) -hook_chat_command('sample', "options and shit", on_sample_play) +hook_chat_command('stream', "[load|play|resume|pause|stop|destroy|getpos]", on_stream_play) +hook_chat_command('sample', "[load|play]", on_sample_play) diff --git a/docs/lua/examples/audio-test/sound/music.mp3 b/docs/lua/examples/audio-test/sound/music.mp3 new file mode 100644 index 00000000..8d3ed0b6 Binary files /dev/null and b/docs/lua/examples/audio-test/sound/music.mp3 differ diff --git a/docs/lua/examples/audio-test/sound/sample.mp3 b/docs/lua/examples/audio-test/sound/sample.mp3 new file mode 100644 index 00000000..fcc55c77 Binary files /dev/null and b/docs/lua/examples/audio-test/sound/sample.mp3 differ diff --git a/docs/lua/examples/audio-test/sound/test.mp3 b/docs/lua/examples/audio-test/sound/test.mp3 deleted file mode 100755 index f57ffa09..00000000 Binary files a/docs/lua/examples/audio-test/sound/test.mp3 and /dev/null differ diff --git a/src/bass_audio/bass_audio_helpers.c b/src/bass_audio/bass_audio_helpers.c index 3bf111c7..48277f04 100644 --- a/src/bass_audio/bass_audio_helpers.c +++ b/src/bass_audio/bass_audio_helpers.c @@ -25,7 +25,7 @@ void bassh_free_sample(HSAMPLE sample) { } void bassh_set_looping(HSTREAM stream, BOOL loop) { - BASS_ChannelFlags(stream, loop == TRUE ? 0 : BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); + BASS_ChannelFlags(stream, loop == TRUE ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); } BOOL bassh_get_looping(HSTREAM stream) { @@ -75,6 +75,7 @@ void bassh_set_speed(HSTREAM stream, float initial_freq, float speed, BOOL pitch } void bassh_set_stream_volume(HSTREAM stream, float volume) { + BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, volume); BASS_ChannelSetAttribute(stream, BASS_ATTRIB_MUSIC_VOL_CHAN, volume); } diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index d08f9bd7..60130a3a 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -375,7 +375,7 @@ void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume) { Mat4 mtx; mtxf_translate(mtx, position); mtxf_mul(mtx, mtx, gCamera->mtx); - f32 factor = 5; + f32 factor = 10; pan = (get_sound_pan(mtx[3][0] * factor, mtx[3][2] * factor) - 0.5f) * 2.0f; }