3

I'm working on a project that generates music. It allows the user to select a wide variety of tunings (n-EDO up to 49000, etc).

I have two methods implemented so far and both rely on MIDI.

  1. Using the MIDI Tuning Standard I send a sysreq with each note corresponding to the required audio frequency of the tuning. The problem -- and this might only be an issue with Timidity -- is that I can only have one note sounding at a time, period. Across all channels. Just one note.

  2. Using MIDI pitch bend which because the pitch bend applies to all notes on a given channel means you can have only 16 notes playing at a time (given that you want each note to have its own pitch bend).

Ok, here's where it gets odd. Using the MTS approach I get 16,384 tones between the base note and the next semitone. Eg, between C and C# there are 16,384 notes.

With pitch bend I get 16,384 stretched between two whole tones (four semitones). Starting with the base note you get +8192 tones to the next whole tone or -8192 tones to the next lower whole tone.

So both approaches use 16,384 values but pitch bend is stretched across two whole tones while the MTS method is compressed to just one semitone.

For evidence here is output from my program showing the pitch bend and sysreq values calculated and that produce the exact same result:

note: 1 pitch = 60 bend = 0.0 sysreq_value = 0.0
note: 2 pitch = 60 bend = 2048.0 sysreq_value = 8192.0
note: 3 pitch = 60 bend = 4096.0 sysreq_value = 16384.0

Note 3 is equivalent to pitch 61 in both approaches with note 2 being a quarter tone.

My questions, does my analysis make sense? And is it possible to tell Timidity (or any MIDI player) to use all 16,384 values of pitch bend for just the one semitone, like some kind of sysreq command at the beginning of the file? Clearly Timidity has the ability to use 16,384 between each semitone it's just a matter of convincing it to.

Update: It now appears that Fluidsynth can use up to 256 channels so that solves one of my problems. Apparently it does not support the MTS so I would have to use pitch bend with it but now the question applies to Fluidsynth -- is there a way to tell it to use 16,384 values for the notes between semitones?

5
  • fluidsynth does do tuning of notes. it may not follow MTS exactly, but i remember seeing some code in it that does tuning. Aug 14, 2016 at 19:27
  • Yeah, I would have thought so. I've asked the mail list twice with no results.
    – bfootdav
    Aug 15, 2016 at 0:50
  • sounds like ya wanna write your own synth anyway. download the source n figure it out. maybe turn it into bfootdavSynth ? Aug 15, 2016 at 2:58
  • God no! I'm a horrible programmer but I figure that any idea I have about music software at least 1,000 good programmers have already had and worked it out. It's just a matter of finding the software and figuring out how to use it.
    – bfootdav
    Aug 15, 2016 at 15:28
  • well ok then. fluidsynth has a kajillion command line parameters. My bet is one of them spec's a text config file with the tunings in it. but no guarantees that FluidSynth actually uses em right. That email list is the only thing ya got. I'd bug em again. I think some guy named Dave is the top guy. Ya could email him directly if ya can come across his email on there. Good luck. Aug 15, 2016 at 16:04

1 Answer 1

5

You can change the range of the pitch bend using RPN messages. See http://www.midikits.net/midi_analyser/pitch_bend.htm, or google "set MIDI pitch bend range" if that link disappears for some reason.

Pitch bend affects all notes on a MIDI channel. If you want to have more polyphony than 16 (one note per channel) while using pitch bend in a way that it was not intended for, the easiest solution is probably to use several MIDI players in parallel and combine the audio output.

You might want to consider setting up the whole playback configuration inside a VST host.

Note, although in theory you can specify pitch bends and tuning commands to high accuracy, there is no guarantee that the player will interpret the commands to the same accuracy. Some players will round the pitch to the nearest cent, i.e. 100 steps per semitone or 1200 steps per octave.

Alternatively, generate the sounds yourself with something like https://en.wikipedia.org/wiki/Csound.

4
  • Thanks alephzero, now I just need to figure out how to properly send those commands to my MIDI file. And since FS allows you to use up to 256 channels that pretty much takes care of the 16 channel limitation. And while I'll be making the MIDI files available most users will just use the FS generated audio files so if it is accurate then so will be the audio files. I've been looking into Csound today and while it is intimidating it might be a good solution. I would need to build a collection of synthesized instruments to replace General MIDI though.
    – bfootdav
    Aug 15, 2016 at 0:47
  • You send RPN (Registered Parameter Number) data by sending CC 101 and CC 100 for the high and low bits of the parameter number, then CC6 for the data value. Pitch bend is RPN #0, so you just sent CC 101,0, CC 100,0, CC6, range in semitones. To "switch off" listening for RPN input in case you accidentally send another CC6, send CC101, 127, CC 100, 127. It looks like FluidSynth uses multiple MIDI ports (up to 16) if you want more than 16 channels. You might need some virtual MIDI cable software (e.g. tobias-erichsen.de/software/loopmidi.html) to connect to several MIDI ports.
    – user19146
    Aug 15, 2016 at 3:41
  • I've been playing around with the control codes and apparently the value you send to CC6 goes both above and below the note. So a semitone of 1 gets you 8192 pitches between each semitone (16384 divided by two directions). What's interesting is that when using the MIDI Tuning Standard with Timidity you would get all 16384 values in one direction meaning 16384 between each semitone. I don't have to have that level of resolution but now I'm curious as to how to get it.
    – bfootdav
    Aug 15, 2016 at 15:26
  • Can't you simply use additional MIDI tracks/ports when 16 channels aren't enough?
    – root
    Aug 4 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.