Various audio fixes, updated audio example
This commit is contained in:
parent
6d6995e5da
commit
cd18f5aa6b
|
@ -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)
|
||||
|
|
Binary file not shown.
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue