html5: webaudio support WIP

main
Dominik Madarász 2023-10-08 19:07:01 +02:00
parent 1ff5ad2767
commit 796839ac74
19 changed files with 91420 additions and 11 deletions

View File

@ -19,5 +19,5 @@ rem cook art
rem host webserver, compile and launch
rem start python -m http.server --bind 127.0.0.1 8000
call emcc %* -g ..\..\engine\v4k.c -I..\..\engine -o index.html -pthread -s FULL_ES3 -s USE_PTHREADS -s USE_GLFW=3 -s SINGLE_FILE=1 -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file .art[00].zip@index.zip -lidbfs.js
call emcc %* -g ..\..\engine\v4k.c -I..\..\engine -o index.html -pthread -s FULL_ES3 -s USE_PTHREADS -s USE_GLFW=3 -s SINGLE_FILE=1 -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file .art[00].zip@index.zip -lidbfs.js
rem emrun index.html

View File

@ -606,7 +606,8 @@ int main(void) {
// 75% sized, msaa x4 enabled
window_create(1, 0);
window_title( "V4K - SPACE pauses simulation" );
audio_t BGM = audio_stream( "waterworld-map.fur" );
audio_play(BGM, 0);
// fx_load("fx**.fs");
// camera that points to origin

View File

@ -135,6 +135,7 @@
{{{ SCRIPT }}}
<button onclick="openFullscreen();" style="position:relative; z-index: 1000; float: right;">&#x26F6;</button>
<!-- <button id="btn-audio" onclick="toggleAudio();" style="position:relative; z-index: 1000; float: right;">M</button> -->
<script>
function openFullscreen() {
var canvas = document.getElementById("canvas");
@ -147,5 +148,35 @@
}
}
</script>
<!-- <script type='text/javascript'>
var audioBtn = document.querySelector('#btn-audio');
// An array of all contexts to resume on the page
const audioContexList = [];
(function() {
// A proxy object to intercept AudioContexts and
// add them to the array for tracking and resuming later
self.AudioContext = new Proxy(self.AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContexList.push(result);
if (result.state == "suspended") audioBtn.value = "RESUME";
return result;
}
});
})();
function toggleAudio() {
var resumed = false;
audioContexList.forEach(ctx => {
if (ctx.state == "suspended") { ctx.resume(); resumed = true; }
else if (ctx.state == "running") ctx.suspend();
});
if (resumed) audioBtn.value = "SUSPEND";
else audioBtn.value = "RESUME";
}
</script> -->
</body>
</html>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,38 @@
SIERRA ON-LINE, INC.
3-D Animated Adventure Game Soundtrack Series
===============================================
LEISURE SUIT LARRY III: PASSIONATE PATTI-
IN PURSUIT OF THE PULSATING PECTORALS
"TAWNI AT THE BEACH"
Mike Dana
===============================================
Copyright (c)1989 Sierra On-Line, Inc.
===============================================
GENERAL MIDI VERSION
System Requirements:
- MIDI Playback Software capable of reading Type 1 Standard
MIDI File format
- General MIDI sound device (Wave Table or better recommended)
This Standard MIDI File was recorded directly from Sierra's "Leisure Suit
Larry 3" adventure game. It has been converted from the MT-32 version for
playback on General MIDI sound cards. A Wave Table or better sound card is
highly recommended for optimal playback.
Recorded/converted for General MIDI by Tom Lewandowski.
Address questions or comments to:
QUEST STUDIOS
Tom Lewandowski
tom@queststudios.com
www.QuestStudios.com

Binary file not shown.

View File

@ -0,0 +1,43 @@
QUEST STUDIOS
SOFTWARE SOUNDTRACK SERIES
====================================================
THE SECRET OF MONKEY ISLAND
"INTRODUCTION/OPENING THEMES"
Michael Z. Land
====================================================
Copyright (c)1989 LucasArts Entertainment Co.
====================================================
G E N E R A L M I D I V E R S I O N
System Requirements:
- MIDI Playback Software capable of reading Type 1 Standard
MIDI File format
- General MIDI sound device (Wave Table recommended.)
This Standard MIDI File was recorded directly from LucasFilm Game's
"The Secret of Monkey Island" adventure game. It has been converted
from the MT-32 version for playback on General MIDI sound cards. A
Wave Table sound card is highly recommended for optimal playback.
Recorded/Converted to Standard MIDI File format by Tom Lewandowski.
Address questions or comments to:
QUEST STUDIOS
Tom Lewandowski
tom+di@netnet.net
THE ROLAND MT-32 SOUND MODULE RESOURCE CENTER
THE SIERRA SOUNDTRACK SERIES/SOFTWARE SOUNDTRACK SERIES
http://bayland.net/~tom+di/sierra/roland.html

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
Licensed under the Public Domain license
Registered Artist(s):
Drozerix

Binary file not shown.

Binary file not shown.

View File

@ -77273,6 +77273,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#line 0
#undef error
#undef DEBUG
#define MA_DEBUG_OUTPUT
#line 1 "3rd_sts_mixer.h"
///////////////////////////////////////////////////////////////////////////////
// sts_mixer.h - v0.02
@ -581555,11 +581556,11 @@ static ma_context context;
static sts_mixer_t mixer;
// This is the function that's used for sending more data to the device for playback.
static ma_uint32 audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
static void audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
int len = frameCount;
sts_mixer_mix_audio(&mixer, pOutput, len / (sizeof(int32_t) / 4));
(void)pDevice; (void)pInput;
return len / (sizeof(int32_t) / 4);
// return len / (sizeof(int32_t) / 4);
}
void audio_drop(void) {
@ -581587,7 +581588,7 @@ int audio_init( int flags ) {
ma_backend_oss,
ma_backend_jack,
ma_backend_opensl,
// ma_backend_webaudio,
ma_backend_webaudio,
//ma_backend_openal,
//ma_backend_sdl,
ma_backend_null // Lowest priority.

91290
engine/split/d.h 100644

File diff suppressed because it is too large Load Diff

View File

@ -112,6 +112,7 @@ errno_t fopen_s(
{{FILE:3rd_stb_vorbis.h}}
#undef error
#undef DEBUG
#define MA_DEBUG_OUTPUT
{{FILE:3rd_sts_mixer.h}}
{{FILE:3rd_miniaudio.h}}
//---

View File

@ -249,11 +249,11 @@ static ma_context context;
static sts_mixer_t mixer;
// This is the function that's used for sending more data to the device for playback.
static ma_uint32 audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
static void audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
int len = frameCount;
sts_mixer_mix_audio(&mixer, pOutput, len / (sizeof(int32_t) / 4));
(void)pDevice; (void)pInput;
return len / (sizeof(int32_t) / 4);
// return len / (sizeof(int32_t) / 4);
}
void audio_drop(void) {
@ -281,7 +281,7 @@ int audio_init( int flags ) {
ma_backend_oss,
ma_backend_jack,
ma_backend_opensl,
// ma_backend_webaudio,
ma_backend_webaudio,
//ma_backend_openal,
//ma_backend_sdl,
ma_backend_null // Lowest priority.

View File

@ -59491,6 +59491,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#line 0
#undef error
#undef DEBUG
#define MA_DEBUG_OUTPUT
#line 1 "3rd_sts_mixer.h"
///////////////////////////////////////////////////////////////////////////////
// sts_mixer.h - v0.02

View File

@ -1262,11 +1262,11 @@ static ma_context context;
static sts_mixer_t mixer;
// This is the function that's used for sending more data to the device for playback.
static ma_uint32 audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
static void audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
int len = frameCount;
sts_mixer_mix_audio(&mixer, pOutput, len / (sizeof(int32_t) / 4));
(void)pDevice; (void)pInput;
return len / (sizeof(int32_t) / 4);
// return len / (sizeof(int32_t) / 4);
}
void audio_drop(void) {
@ -1294,7 +1294,7 @@ int audio_init( int flags ) {
ma_backend_oss,
ma_backend_jack,
ma_backend_opensl,
// ma_backend_webaudio,
ma_backend_webaudio,
//ma_backend_openal,
//ma_backend_sdl,
ma_backend_null // Lowest priority.