SkyEmu
SkyEmu copied to clipboard
No sound in web version
When using the web app based build there is no sound. Tested it with an iPhone 13 and iOS 15.
Can you check to make sure the ringer switch on the side of the phone is not set to silent/vibrate? iOS has a quirk where it mixes webaudio through the ringer channel on the phone rather than the audio/media channel. So, muting the ringer also mutes webaudio.
@skylersaleh One question is it planned that you create a native build for iOS/iPadOS and provide it as .ipa file? Then it is possible to install the SkyEmu app on jailbroken devices.
I know fix
make a cover div have a button, "click countine run"
<div class="g-mobile-click" hidden>click countine run</div>
<style>
.g-mobile-click {
position: absolute;
width: 180px;
height: 24px;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
z-index: 9999;
}
</style>
Replace SkyEmu.js
js.replace(
/document\.addEventListener\("click",\s?resume_webaudio,\s?\{\n?\s*once: true\n?\s*\}\);/,
`
document.addEventListener("click", resume_webaudio, {
once: true
});
Module.audioReset = ()=>{
if (document.querySelector('.g-mobile-click').hidden||Module._saudio_context.state != "running") {
document.querySelector('.g-mobile-click').hidden = false;
return 0;
}
return Module._saudio_node.bufferSize
};
document.querySelector('.g-mobile-click').addEventListener("pointerup", () => {
document.querySelector('.g-mobile-click').hidden = true;
if (Module._saudio_context.state != "suspended") {
Module._saudio_context = new AudioContext({
sampleRate: sample_rate,
latencyHint: "interactive"
});
console.log("sokol_audio.h: sample rate ", Module._saudio_context.sampleRate);
Module._saudio_node = Module._saudio_context.createScriptProcessor(buffer_size, 0, num_channels);
Module._saudio_node.onaudioprocess = function pump_audio(event) {
var num_frames = event.outputBuffer.length;
var ptr = __saudio_emsc_pull(num_frames);
if (ptr) {
var num_channels = event.outputBuffer.numberOfChannels;
for (var chn = 0; chn < num_channels; chn++) {
var chan = event.outputBuffer.getChannelData(chn);
for (var i = 0; i < num_frames; i++) {
chan[i] = HEAPF32[(ptr >> 2) + (num_channels * i + chn)]
}
}
}
};
Module._saudio_node.connect(Module._saudio_context.destination);
}
resume_webaudio();
}, {
passive: false
});
`
).replace(
/function\s?saudio_js_buffer_frames\(\)\s?\{/,
'function saudio_js_buffer_frames() {if(Module.audioReset)return Module.audioReset();'
)
@skylersaleh One question is it planned that you create a native build for iOS/iPadOS and provide it as .ipa file? Then it is possible to install the SkyEmu app on jailbroken devices.
Funnily enough, all the core code should be there for this. The big hurdle would be just setting up the github workflows and build system to perform the build.