Ori Spokoini
08/09/2025, 9:43 AMawait audioContext.audioWorklet.addModule("hiss-generator.js");
// hiss-generator.js
registerProcessor("hiss-generator", HissGeneratorProcessor);
I tried to creating the processor in another module with:
// processor/build.gradle.kts
commonWebpackConfig {
outputFileName = "audio-processor.js"
}
But when I add it as a dependency to the app, audio-processor.js isnโt included in the dist output.
What am I missing?turansky
08/09/2025, 12:16 PMturansky
08/09/2025, 1:06 PMWorker creation without separate subproject creation - example.turansky
08/09/2025, 1:07 PMturansky
08/09/2025, 1:17 PMturansky
08/09/2025, 1:47 PMOri Spokoini
08/09/2025, 1:47 PMturansky
08/09/2025, 1:54 PM// MyAydioWorkletModule.kt
val MyAydioWorkletModule = AudioWorkletModule {
// this - AudioWorkletGlobalScope
}
// App.kt
audioContext.audioWorklet.addModule(MyAydioWorkletModule)
All additional magic Vite and Seskar will do ๐Ori Spokoini
08/09/2025, 2:01 PMturansky
08/09/2025, 3:08 PMOri Spokoini
08/14/2025, 2:27 PMturansky
08/14/2025, 2:30 PMturansky
08/14/2025, 2:30 PMturansky
08/16/2025, 2:16 AMturansky
08/16/2025, 2:16 AMturansky
08/18/2025, 1:40 AMdwursteisen
10/15/2025, 6:28 PM./gradlew jsViteDev , it's working: the worklet is loaded in the browser and it's working as expected. (it's loading the *.mjs audio module)
But I was not able to make it work using the task jsBundleProduction : the audio worklet is not created. When updating the vite configuration to use the Audio Worklet as entry point
rollupOptions: {
input: {
// HTML entry point - relative to root (kotlin directory)
main: resolve(__dirname, 'kotlin/index.html'),
// Audio worklet entry point (will be bundled separately)
'audio-worklet': resolve(__dirname, 'kotlin/HissGeneratorWorkletModule__worklet__module.mjs')
},
}
It's not working also as it generated a base64 string of the mjs file (without resolving its dependencies.)
I tried the same thing using this test from seskar and use the same command: the audio worklet is not generated also using ./gradlew jsBundleProduction. (see build/dist/js/production)
is the audio worklet can be bundled using vite and ./gradlew jsBundleProduction?
I do believe that it's a configuration issue with vite so it can generate the right bundle with the audio worklet. But as a fresh user of vite, I'm bit lost at the moment. Could you point me what to do to fix this issue?
thanks ๐turansky
10/15/2025, 6:34 PMdwursteisen
10/15/2025, 6:58 PMnpm dependencies in my project.
If I decode the base64 string from the generated audio worklet javascript file,
I can see import of mjs files: (example below)
import { Unit_instance1fbcbse1fwigr as Unit_instance } from '../kotlin-kotlin-stdlib/kotlin/Unit.mjs';
But as files are bundle, there is no mjs to download.
You can reproduce the issue by using this vite.config.mjs with the seskar example.
import { defineConfig } from 'vite'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
export default defineConfig({
root: "kotlin",
build: {
rollupOptions: {
input: {
// HTML entry point - relative to root (kotlin directory)
main: resolve(__dirname, 'kotlin/index.html'),
'audio-worklet': resolve(__dirname, 'kotlin/mdn-audioworklet-example/mdn/audioworklet/example/HissGeneratorWorkletModule__worklet__module.mjs'),
},
}
}
})
By using the command: ./gradlew jsBrowserProductionVite --rerun-tasks,
The audio-worklet.js in seskar/tests/worklets/mdn-audioworklet-example/build/dist/js/production will contains a base64 string to be decoded by the javascript code.
If i'm serving the content of this directory (python3 -m http.server 8000) the page is not working and crash when playing an audio because Failed to resolve module specifier "./HissGeneratorParameters.mjs".
Am I doing something wrong? ๐คturansky
10/15/2025, 7:34 PMdwursteisen
10/15/2025, 7:45 PMturansky
10/15/2025, 8:29 PMWorker class can be used as workaroundturansky
10/15/2025, 8:29 PMincludeBuild ? ๐dwursteisen
10/15/2025, 9:43 PMturansky
10/16/2025, 6:56 AMturansky
10/16/2025, 12:25 PMimportScripts (and fail worklet)turansky
10/16/2025, 1:15 PMturansky
10/16/2025, 1:15 PMincludeBuild) if it work's for you?turansky
10/16/2025, 1:16 PMhttps server required for checkdwursteisen
10/16/2025, 3:12 PMhttps server is required? I'm using an http server only. With an audio worklet created by myself, in Javascript. it was working with a http only server.turansky
10/26/2025, 10:53 PMturansky
10/26/2025, 10:55 PMprocess method override in production without reason.
cc @Artem Kobzarturansky
10/26/2025, 10:55 PMdwursteisen
10/26/2025, 10:56 PMturansky
10/26/2025, 11:17 PM