mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-10-19 03:32:41 +00:00
Various audio fixes, updated audio example
This commit is contained in:
parent
725e26fe83
commit
a722afe122
6 changed files with 23 additions and 29 deletions
|
@ -1,68 +1,61 @@
|
||||||
-- name: Audio Test
|
-- name: Audio Test
|
||||||
-- description: audio shits.
|
-- description: Testing out the custom audio system
|
||||||
-- incompatible:
|
-- incompatible:
|
||||||
|
|
||||||
DEBUG = false
|
audioStream = nil;
|
||||||
UNST22 = true -- gotta work around unst 22 bugs :(
|
audioSample = nil;
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
function on_stream_play(msg)
|
||||||
|
if(msg == "load") then
|
||||||
handle = 0;
|
audioStream = audio_stream_load("music.mp3")
|
||||||
s_handle = 0;
|
audio_stream_set_looping(audioStream, true)
|
||||||
|
djui_chat_message_create("audio audioStream:" .. tostring(audioStream));
|
||||||
function on_audio_play(msg)
|
|
||||||
if(msg == "create") then
|
|
||||||
handle = load_audio("test.mp3")
|
|
||||||
|
|
||||||
djui_chat_message_create("audio handle:" .. tostring(handle));
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if(msg == "play") then
|
if(msg == "play") then
|
||||||
play_audio(handle, true);
|
audio_stream_play(audioStream, true, 1);
|
||||||
djui_chat_message_create("playing audio");
|
djui_chat_message_create("playing audio");
|
||||||
end
|
end
|
||||||
|
|
||||||
if(msg == "resume") then
|
if(msg == "resume") then
|
||||||
play_audio(handle, false);
|
audio_stream_play(audioStream, false, 1);
|
||||||
djui_chat_message_create("resuming audio");
|
djui_chat_message_create("resuming audio");
|
||||||
end
|
end
|
||||||
|
|
||||||
if(msg == "pause") then
|
if(msg == "pause") then
|
||||||
pause_audio(handle);
|
audio_stream_pause(audioStream);
|
||||||
djui_chat_message_create("pausing audio");
|
djui_chat_message_create("pausing audio");
|
||||||
end
|
end
|
||||||
|
|
||||||
if(msg == "stop") then
|
if(msg == "stop") then
|
||||||
stop_audio(handle);
|
audio_stream_stop(audioStream);
|
||||||
djui_chat_message_create("stopping audio");
|
djui_chat_message_create("stopping audio");
|
||||||
end
|
end
|
||||||
|
|
||||||
if(msg == "destroy") then
|
if(msg == "destroy") then
|
||||||
destroy_audio(handle);
|
audio_stream_destroy(audioStream);
|
||||||
djui_chat_message_create("destroyed audio");
|
djui_chat_message_create("destroyed audio");
|
||||||
end
|
end
|
||||||
|
|
||||||
if(msg == "getpos") then
|
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
|
end
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_sample_play(msg)
|
function on_sample_play(msg)
|
||||||
if(msg == "create") then
|
if(msg == "load") then
|
||||||
s_handle = load_sample("test.mp3");
|
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;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
handle2 = get_audio_from_sample(s_handle);
|
audio_sample_play(audioSample, gMarioStates[0].pos, 1);
|
||||||
|
|
||||||
play_audio(handle2, false);
|
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
hook_chat_command('audio', "options and shit", on_audio_play)
|
hook_chat_command('stream', "[load|play|resume|pause|stop|destroy|getpos]", on_stream_play)
|
||||||
hook_chat_command('sample', "options and shit", on_sample_play)
|
hook_chat_command('sample', "[load|play]", on_sample_play)
|
||||||
|
|
BIN
docs/lua/examples/audio-test/sound/music.mp3
Normal file
BIN
docs/lua/examples/audio-test/sound/music.mp3
Normal file
Binary file not shown.
BIN
docs/lua/examples/audio-test/sound/sample.mp3
Normal file
BIN
docs/lua/examples/audio-test/sound/sample.mp3
Normal file
Binary file not shown.
Binary file not shown.
|
@ -25,7 +25,7 @@ void bassh_free_sample(HSAMPLE sample) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void bassh_set_looping(HSTREAM stream, BOOL loop) {
|
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) {
|
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) {
|
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);
|
BASS_ChannelSetAttribute(stream, BASS_ATTRIB_MUSIC_VOL_CHAN, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -375,7 +375,7 @@ void audio_sample_play(struct BassAudio* audio, Vec3f position, f32 volume) {
|
||||||
Mat4 mtx;
|
Mat4 mtx;
|
||||||
mtxf_translate(mtx, position);
|
mtxf_translate(mtx, position);
|
||||||
mtxf_mul(mtx, mtx, gCamera->mtx);
|
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;
|
pan = (get_sound_pan(mtx[3][0] * factor, mtx[3][2] * factor) - 0.5f) * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue