mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Add function to load music via https URLs (#100)
This commit is contained in:
parent
3eed46a2a1
commit
499518adde
6 changed files with 50 additions and 1 deletions
|
|
@ -7211,6 +7211,12 @@ function audio_stream_load(filename)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param url string
|
||||||
|
--- @return BassAudio
|
||||||
|
function audio_stream_loadURL(url)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param audio BassAudio
|
--- @param audio BassAudio
|
||||||
--- @return nil
|
--- @return nil
|
||||||
function audio_stream_pause(audio)
|
function audio_stream_pause(audio)
|
||||||
|
|
|
||||||
|
|
@ -4767,6 +4767,26 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [audio_stream_loadURL](#audio_stream_loadURL)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local BassAudioValue = audio_stream_loadURL(url)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| url | `string` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
[BassAudio](structs.md#BassAudio)
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`struct BassAudio* audio_stream_loadURL(const char* url);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [audio_stream_pause](#audio_stream_pause)
|
## [audio_stream_pause](#audio_stream_pause)
|
||||||
|
|
||||||
### Lua Example
|
### Lua Example
|
||||||
|
|
|
||||||
|
|
@ -1344,6 +1344,7 @@
|
||||||
- [audio_stream_get_tempo](functions-4.md#audio_stream_get_tempo)
|
- [audio_stream_get_tempo](functions-4.md#audio_stream_get_tempo)
|
||||||
- [audio_stream_get_volume](functions-4.md#audio_stream_get_volume)
|
- [audio_stream_get_volume](functions-4.md#audio_stream_get_volume)
|
||||||
- [audio_stream_load](functions-4.md#audio_stream_load)
|
- [audio_stream_load](functions-4.md#audio_stream_load)
|
||||||
|
- [audio_stream_loadURL](functions-4.md#audio_stream_loadURL)
|
||||||
- [audio_stream_pause](functions-4.md#audio_stream_pause)
|
- [audio_stream_pause](functions-4.md#audio_stream_pause)
|
||||||
- [audio_stream_play](functions-4.md#audio_stream_play)
|
- [audio_stream_play](functions-4.md#audio_stream_play)
|
||||||
- [audio_stream_set_frequency](functions-4.md#audio_stream_set_frequency)
|
- [audio_stream_set_frequency](functions-4.md#audio_stream_set_frequency)
|
||||||
|
|
|
||||||
|
|
@ -14857,6 +14857,17 @@ int smlua_func_audio_stream_load(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_audio_stream_loadURL(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||||
|
|
||||||
|
const char* url = smlua_to_string(L, 1);
|
||||||
|
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||||
|
|
||||||
|
smlua_push_object(L, LOT_BASSAUDIO, audio_stream_loadURL(url));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int smlua_func_audio_stream_pause(lua_State* L) {
|
int smlua_func_audio_stream_pause(lua_State* L) {
|
||||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||||
|
|
||||||
|
|
@ -17565,6 +17576,7 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo);
|
smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo);
|
||||||
smlua_bind_function(L, "audio_stream_get_volume", smlua_func_audio_stream_get_volume);
|
smlua_bind_function(L, "audio_stream_get_volume", smlua_func_audio_stream_get_volume);
|
||||||
smlua_bind_function(L, "audio_stream_load", smlua_func_audio_stream_load);
|
smlua_bind_function(L, "audio_stream_load", smlua_func_audio_stream_load);
|
||||||
|
smlua_bind_function(L, "audio_stream_loadURL", smlua_func_audio_stream_loadURL);
|
||||||
smlua_bind_function(L, "audio_stream_pause", smlua_func_audio_stream_pause);
|
smlua_bind_function(L, "audio_stream_pause", smlua_func_audio_stream_pause);
|
||||||
smlua_bind_function(L, "audio_stream_play", smlua_func_audio_stream_play);
|
smlua_bind_function(L, "audio_stream_play", smlua_func_audio_stream_play);
|
||||||
smlua_bind_function(L, "audio_stream_set_frequency", smlua_func_audio_stream_set_frequency);
|
smlua_bind_function(L, "audio_stream_set_frequency", smlua_func_audio_stream_set_frequency);
|
||||||
|
|
|
||||||
|
|
@ -422,4 +422,12 @@ void audio_custom_shutdown(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sBassAudioCount = 0;
|
sBassAudioCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct BassAudio* audio_stream_loadURL(const char* url) {
|
||||||
|
HSTREAM stream = BASS_StreamCreateURL(url, 0, 0, NULL, NULL);
|
||||||
|
struct BassAudio* res = malloc(sizeof(struct BassAudio));
|
||||||
|
res->handle = stream;
|
||||||
|
res->rawData = NULL;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ void audio_stream_set_tempo(struct BassAudio* audio, f32 tempo);
|
||||||
f32 audio_stream_get_volume(struct BassAudio* audio);
|
f32 audio_stream_get_volume(struct BassAudio* audio);
|
||||||
void audio_stream_set_volume(struct BassAudio* audio, f32 volume);
|
void audio_stream_set_volume(struct BassAudio* audio, f32 volume);
|
||||||
void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch);
|
void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch);
|
||||||
|
struct BassAudio* audio_stream_loadURL(const char* url);
|
||||||
|
|
||||||
|
|
||||||
struct BassAudio* audio_sample_load(const char* filename);
|
struct BassAudio* audio_sample_load(const char* filename);
|
||||||
void audio_sample_destroy(struct BassAudio* audio);
|
void audio_sample_destroy(struct BassAudio* audio);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue