flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > Midi synth/sequencer

Author
Thread Post new topic Reply to topic
Ville



Joined: 17 Jun 2003
Posts: 324
Ville 06 Nov 2025, 15:18
You can use upto 256 instruments, which receive at differerent midi channels and note ranges. It has displays for sequencer tracks, synth, mixer, piano roll and notation. Menuet scheduler runs at 1000hz and can be set as high as 100000hz (100khz), so the limiting latency factor is usually sound cards buffer length.


Description:
Filesize: 295.23 KB
Viewed: 1188 Time(s)

SYNS2b2.png


Post 06 Nov 2025, 15:18
View user's profile Send private message Reply with quote
bzt



Joined: 09 Nov 2018
Posts: 98
bzt 08 Dec 2025, 17:39
MenuetOS always amazes me! Awesome. I have a question though.

Ville wrote:
You can use upto 256 instruments
MIDI has 128 instruments in total, so I guess you wanted to write 256 parallel voices maybe (maximum is 16384 voices = all 128 possible notes played on all 128 instruments at once)?

But my real question is, how do you generate the PCM waveforms for these instruments? I can see on the left screenshot that wave banks are tweakable, but how do you get them in the first place? Do you use a sound font? Or did you also port some synthetizer like fluidsynth or an OPL emulator? Or did you just wrote an arbitrary wave generator with customizable parameters?

Either way, very very impressive! MIDI playback without a dedicated hardware is quite some feat! (Actually my Linux box with the latest MuseScore and Rosegarden software is not up to the task of playing MIDI files... I had to grab a quick-and-dirty player source with built-in OPL emulator from github and compile that myself)
Post 08 Dec 2025, 17:39
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 324
Ville 09 Dec 2025, 14:56
There are different ways to map the synthesizers instrument from the midi track.

1) By midi channel and note position (keyboard split).
2) By tracks instrument setting and note position.
3) Using General Midi mapping, where drum midi channel 10 instruments
(35 bass drum - 81 triangle) are mapped to synth instruments 135-181,
so you dont have to worry about splitting the keyboard for each drum.

You can select which mapping to use from the drop-down menu.

The audio-wave is generated from

1) Waveform generator, which generates waves from preset options, like basic sine, square, sawtooth etc. with additive synthesis.
2) Waveform file from usb stick or hd.

Parameters (envelope, wave settings, phase, pan, etc) are set by user for each instrument.

Playing the notes is pretty straight forward. Notes are just fetched in time order and the synth/sampler instrument is selected based on the above rules. The wave-form is written to the audio buffer according to instruments pan, volume, phase, envelope settings, etc. This happens in real-time, writing the notes to audio buffer a few seconds ahead of current play position, so you can modify the synth/mixer settings in real-time while playing. (I wrote all code.)

btw, I wish they would have kept the easy to approach protocol for Midi 2.0 and simply multiplied the bit-widths and added new features as system exclusive messages. But I quess thats a different conversation Smile
Post 09 Dec 2025, 14:56
View user's profile Send private message Reply with quote
bzt



Joined: 09 Nov 2018
Posts: 98
bzt 10 Dec 2025, 10:20
Ville wrote:
Waveform generator, which generates waves from preset options, like basic sine, square, sawtooth etc. with additive synthesis.
Yes, I got that, my question was, what kind of waveform generator do yo use?
1. Soundfont is a collection of parameters for a standardized set of synth methods (typical example fluidsynth)
2. OPL is a software emulation of the YM3812 / YM262 / etc. chips, so here an instrument is a set of register values (for example, but ymfmidi reads the actual register values from this file)
3. Custom waveform generator (for example like this player)

With all these, you have some kind of "presets" to combine and transform basic waveforms. The difference is how this is implemented. For 1. you have some high level abstraction and variable length parameter records, for 2. you have fixed sized records with register values, and for 3. well, custom, so whatever.

(FYI IMHO option 1. is unnecessarily overcomplicated should be avoided, 2. is the best compromise between quality and complexity, but only needed if recreating that old Adlib/SoundBlaster vibe is the aim, therefore most of the time option 3. is more than sufficient.)
Ville wrote:
Waveform file from usb stick or hd.
Yes, I saw the "Wavefile" button Smile Pretty neat, MIDI players usually stuck in chiptune wavegen hell and never use high quality PCM samples for some reason. So really awesome!
Post 10 Dec 2025, 10:20
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 324
Ville 11 Dec 2025, 18:05
The waveform generator is a custom synthesizer, which is likely closest to OPL. The synthesizer reads parameters from user definable registers, which control how oscillators and all other wave properties behave. And the parameters are saved as fixed length record for all instruments.
bzt wrote:
2. is the best compromise between quality and complexity

So yes, Ive come to the same conclusion.
Post 11 Dec 2025, 18:05
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 844
Ali.Z 14 Dec 2025, 08:29
do you intend to make a tracker at some point Rolling Eyes (e.g. like ft2)

_________________
Asm For Wise Humans
Post 14 Dec 2025, 08:29
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 324
Ville 15 Dec 2025, 12:06
I cant promise anything, but the tracker interface is very interesting. It provides a completely different view for the creative process.
Post 15 Dec 2025, 12:06
View user's profile Send private message Reply with quote
bzt



Joined: 09 Nov 2018
Posts: 98
bzt 18 Dec 2025, 01:51
Ville wrote:
I cant promise anything, but the tracker interface is very interesting. It provides a completely different view for the creative process.
If you end up writing a tracker, here's some help. (if not, then sorry for bothering you)

Here's my battle-proven code that converts MIDI tracks into tracker rows (the used tracker row format is 99.9% the same as ft2's .xm format). You won't be able to use this code as-is because it's in C, but it will help you to understand the concept behind trackers, the nuances in the differences. The source is full of comments and explanations.

I've written quite a lot on this topic in the manual too, which might be useful. It explains how a tracker interface is built up and used, and there's also a side-by-side comparison example (which uses the note sheet from the MIDI spec as an example).

As for the format itself, the predecessor Amiga MOD is a pretty simple format, see .mod specification. You must be familiar with that to make sense of the ft2's .xm spec. Note that about 50%-60% of that latter spec is totally unnecessary (as they're specific to a particular tracker and not widely used): safe to skip ADPCM (nobody uses it due to poor quality), skip "stripped module" part, pattern compression, etc. it's okay to only focus on instruments (samples, envelopes) and patterns (note sheets), forget the rest.

Oh, important note, not obvious from the spec: tracker's "channel" is not the same as MIDI's "channel", nor as in a WAVE file "channels". For trackers "channel" is the mixer's capacity.


Last edited by bzt on 18 Dec 2025, 02:18; edited 1 time in total
Post 18 Dec 2025, 01:51
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 844
Ali.Z 18 Dec 2025, 02:13
bzt wrote:
ft2's .xm spec

check this, they claim to have 1:1 clone of ft2 and pro tracker 2:
https://16-bits.org/

_________________
Asm For Wise Humans
Post 18 Dec 2025, 02:13
View user's profile Send private message Reply with quote
bzt



Joined: 09 Nov 2018
Posts: 98
bzt 18 Dec 2025, 02:36
I can confirm that that ft2-clone is pretty good (but not 1:1, it knows more than the old DOS version). However lately I prefer MilkyTracker (really featurefull).

For a very small, totally bloat-free and dependency-free player I'd recommend to take a look at pocketmod, it's in C and .mod only (so not .xm), but it's just 700 SLoC and heavily commented, good read. (The most used is probably libxmp, but that's not exactly an easy to follow source.)
Post 18 Dec 2025, 02:36
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 844
Ali.Z 18 Dec 2025, 02:47
yes milky tracker is really good, midi, generator, etc.

I forgot to mention uFmod, I used it few times, not the best player, some xm's dont seem to be played correctly, however it is an honorable mention that it is written in fasm.

https://ufmod.sourceforge.io/

_________________
Asm For Wise Humans
Post 18 Dec 2025, 02:47
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 324
Ville 19 Dec 2025, 20:52
bzt wrote:
I've written quite a lot on this topic in the manual,
I especially liked the comparison between traditional notes and tracker display events. Tracker channels could be under the hood processed as midi tracks, each containing only one audible note at a time. And then for editing, converted and displayed in tracker format. So tracker view would simply be one more display type for sequencer. That would be enought for using midiplayers own synth/sample audio.

Another project would be adding support for other track and synth formats, maintaining compatibility with the original sounds. And in principle, you could already write a general midi synth setup (or other audio setup) for the current midiplay, since it saves mixer settings, all 256 synths and sample addresses to a single file.
Post 19 Dec 2025, 20:52
View user's profile Send private message Reply with quote
Ville



Joined: 17 Jun 2003
Posts: 324
Ville 27 Dec 2025, 08:31
Tracker display for midiplay is now included to 1.57.60. It has basic functionality, so you can edit notes and loops in both tracker and piano roll. Tracker loop length and quantize level are saved as general text event (0xff,0x01) to midi1 -file.
Post 27 Dec 2025, 08:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.