Download README.md from KGAudioLab/InstVELA-models-onnx: direct link, hf CLI and curl.
- Browser
- Download file 13.1 kB
-
https://huggingface.co/KGAudioLab/InstVELA-models-onnx/resolve/main/README.md
- Command line
-
hf download hf://KGAudioLab/InstVELA-models-onnx/README.md
-
curl -L -o README.md https://huggingface.co/KGAudioLab/InstVELA-models-onnx/resolve/main/README.md
license: other
license_name: instvela-model-license
license_link: LICENSE
tags:
- onnx
- onnxruntime-web
- music-generation
- midi-to-audio
- webgpu
InstVELA M01Preview · ONNX
Hear your MIDI as an expressive string performance.
InstVELA M01Preview is a browser-based virtual instrument for violin, viola, cello, and double bass. Load a MIDI file, choose an instrument, and click Generate to render 48 kHz string audio with pitch movement and within-note dynamics.
Try another take of the same part. Open Advanced settings and change the Seed to hear a different performance, or adjust Pitch expression to control the amount of pitch movement. M01Preview supports sustain, spiccato, and pizzicato through optional MIDI keyswitches.
Render and export on your device. Your MIDI, settings, and generated audio stay in the browser until you save them locally. After setup, the local Vite server supplies the app, runtime, and model files, so you can render offline.
Faster-than-real-time rendering on M5 MacBook Air
Each model rendered 27.5 seconds of audio on a MacBook Air with an Apple M5 and 32 GB of memory. Timings cover the interval from clicking Generate to the MP3 being ready, with the models already loaded.
| Instrument | Median render time | Speed |
|---|---|---|
| Violin | 7.0 s | 3.9× real time |
| Viola | 7.2 s | 3.8× real time |
| Cello | 7.3 s | 3.8× real time |
| Double bass | 11.9 s | 2.3× real time |
Measured in headless Chrome 157.0.8103.51 on macOS 27.0, with WebGPU running all five ONNX graphs. Each instrument received the same 57-note test phrase transposed into its range. The benchmarks predate stereo Hall reverb and use the 3-second model tail and 320 kbps mono MP3 encoding. The figures are the median of three timed renders after one warm-up.
Run the browser demo
Download the release with the Hugging Face CLI, then run the demo with Node.js 20 or later.
hf download KGAudioLab/InstVELA-models-onnx --local-dir InstVELA-models-onnx
cd InstVELA-models-onnx/demo
npm ci
npm run dev
Open the demo to load the violin example. Switch to Viola or Cello to load the corresponding transposed example. Choose Upload your own MIDI below the piano roll to replace the example with your file. Drag a note vertically to change its pitch. Once the status reads Models ready, click Generate. After rendering, a pitch edit or a change to the render settings enables Generate again. The Vite server serves the app, runtime, and model files. A browser worker runs the models and encodes the output. Open the demo
At startup the demo reads demo/public/config.json. The first entry under models is the default instrument. A ?models=<model> link opens a specific entry, and show_in_menu controls whether the entry appears in the selector. Each model has its own playable MIDI range, keyswitches (sustain, spiccato, pizzicato, in that order), demo song, and render defaults. Use a bundled filename from demo/songs or a path relative to demo/public for demo_midi. The file also holds the shared MIDI processing, Hall mix, MP3 encoding, zoom, and automatic thread settings. Refresh the page after editing the file.
| Instrument | Model bundle | Open in the demo | MIDI keyswitches |
|---|---|---|---|
| Violin | m01-violin-onnx-v1 |
Violin | 36–38 (C2–D2) |
| Viola | m01-viola-onnx-v1 |
Viola | 36–38 (C2–D2) |
| Cello | m01-cello-onnx-v1 |
Cello | 24–26 (C1–D1) |
| Double bass | m01-double-bass-onnx-v1 |
Double bass | 12–14 (C0–D0) |
Load a MIDI file with a fixed tempo and time signature. M01Preview renders one musical note at a time. The demo shortens overlaps, keeps the highest note at each shared onset, and marks the removed material in the piano roll. Inference ignores MIDI Control Change (CC) messages. The demo reads keyswitches separately using the selected instrument’s Keyswitches table. Notes start in sustain, and each keyswitch selects an articulation until the next switch. A file without keyswitches plays entirely in sustain. The v1 training renders used sustain for tremolo, so legacy tremolo keyswitches select sustain. For files with custom keys, enter a Pitch map (optional JSON).
The browser checks model file hashes against each bundle's manifest and runs a startup reference check before using a graph on WebGPU. It falls back to WebAssembly per graph. The device indicator shows the backend in use.
Model architecture
M01Preview follows Melisma's staged synthesis design. The three training stages are the VAE and vocoder, residual F0 generator, and acoustic generator. At inference, the residual F0 generator realizes the pitch and voicing from the score, the acoustic generator produces the corresponding latent sequence, and the vocoder renders the waveform. The four instrument bundles use the M01 S configuration, with a wider harmonic source in the double-bass vocoder.
1. Variational autoencoder and neural source-filter vocoder
- VAE encoder. A complex STFT with a hop of 240 samples produces a frame every 5 ms. The encoder concatenates the real and imaginary components, projects them to 256 channels, and applies three 1D residual blocks. A two-part output head predicts the mean and log variance of a diagonal Gaussian. A sample from this distribution gives a 48-dimensional latent vector per frame. The FFT size is 1,024 for violin, viola, and cello and 2,048 for double bass.
- NSF–HiFi-GAN decoder. The vocoder projects the latents to 320 channels and upsamples time by factors of 5, 4, 4, and 3, reducing the channel widths to 160, 80, 40, and 20. Each stage adds a projection of the source signal and averages three parallel residual branches with different kernel sizes. A final convolution and tanh produce 240 waveform samples per latent frame, or 48 kHz at 200 frames per second.
- Harmonic source. F0 in hertz drives a bank of sinusoids. Voicing controls the harmonic component, and unvoiced frames use noise excitation. Violin, viola, and cello use nine sinusoids including the fundamental. The double-bass v2 vocoder uses 128, which extends the harmonic coverage at low pitches. In the demo, the vocoder carries oscillator phase across chunks and renders with 1 second of context where available on each side. The default chunk is 3 seconds for double bass and 30 seconds for the other instruments.
The encoder and decoder are trained together with mel reconstruction and KL regularization. Multi-period and multi-resolution discriminators provide adversarial and feature-matching losses. At inference, the acoustic flow supplies the latents and vocoder.onnx decodes them.
2. Residual F0 generator
- Score conditioning. The MIDI frontend builds 200 Hz frames with 18 continuous features for pitch, timing, meter, tempo, and velocity, plus four categories for note state, articulation, note connection, and instrument.
f0_cond.onnxconcatenates four learned 16-dimensional embeddings with the standardized continuous features. A two-layer MLP projects the result to a 128-dimensional condition for each frame. - Flow network.
f0_step.onnxcombines that condition with the current normalized residual, known residual values, and the known-frame mask. A 1D convolution produces 128 channels at 200 Hz. A stride-2 convolution reduces the rate to 100 Hz for four bidirectional Transformer blocks with four attention heads, relative position bias, and a flow-time embedding. A transposed convolution restores the 200 Hz rate and adds the skip from the input stem. - Outputs. Two heads predict the flow velocity for the residual and a voicing logit for each frame. The browser takes voicing from the final model evaluation and reconstructs pitch in MIDI semitones as
reference pitch + pitch expression × residual. This gives the pitch contour an explicit score reference and lets the user adjust the magnitude of pitch deviations.
3. Acoustic latent generator
- Inputs. The acoustic branch has its own learned score projection,
ac_cond.onnx.ac_step.onnxcombines its 128-dimensional condition with the generated F0 in MIDI semitones, binary voicing, the current 48-channel latent state, and the known latent prefix and its mask. - U-Net backbone. Two residual encoder stages operate at 200 Hz and 100 Hz with 96 and 160 channels. The bottleneck runs at 50 Hz with four bidirectional Transformer blocks, 256 channels, and eight attention heads. Two transposed convolutions restore the frame rate. At each resolution, the decoder concatenates the corresponding encoder features through a skip connection and applies a residual block. The residual blocks and Transformer receive the flow-time embedding.
- Output. A convolution predicts a 48-channel flow velocity at 200 Hz. After integration, the browser reverses the per-channel normalization to obtain 48-dimensional latents in the VAE's units. The vocoder receives these latents together with F0 converted to hertz and the voicing track.
How the conditioning and flow graphs work together
Each generator's score projection and flow network are optimized together and saved in the same training checkpoint. The two generators learn their own projection weights. The ONNX split lets the browser compute the score projection once for the entire MIDI part and reuse its output at every flow step. The step graph evaluates the update direction for the current state and flow time. JavaScript starts from seeded noise and applies the Euler update state ← state + Δt × flow velocity, using 16 steps per generator by default with classifier-free guidance.
Both generators run in 8-second windows by default. After the first window, the browser supplies a 2-second prefix from the preceding output as known context. It preserves that prefix when assembling the pitch and latent tracks.
ONNX bundle layout
Each bundle contains five ONNX opset 17 graphs.
| Graph | Role |
|---|---|
f0_cond.onnx |
Projects score frames for the pitch generator. |
f0_step.onnx |
Evaluates one residual-F0 flow step and predicts voicing logits. |
ac_cond.onnx |
Projects score frames for the acoustic generator. |
ac_step.onnx |
Evaluates one F0-conditioned acoustic flow step. |
vocoder.onnx |
Decodes latents and pitch excitation into a waveform. |
m01_constants.json defines feature scaling and signal dimensions. manifest.json records export checks and SHA-256 hashes. selftest/ supplies reference tensors for backend checks. For custom integration, see the tensor construction, sampling loops, and chunk assembly in the JavaScript inference driver.
Citation
M01Preview takes its high-level synthesis approach from Sakana Nakasako's Melisma, IPSJ SIG Technical Report, Vol. 2024-MUS-141, No. 2, pp. 1–6, August 26, 2024. IPSJ publication record
License and attribution
The release uses Apache License 2.0 terms with an additional attribution condition. Credit InstVELA M01Preview ONNX and its author, Xiaohan Tian @ KGAudioLab, when redistributing the models, continuing training or fine-tuning them, or using their generated outputs to train another model. License terms
Suggested credit
Uses InstVELA M01Preview by Xiaohan Tian @ KGAudioLab. Model repository



