SynthMaker

Tun Files, Parsing and using.

Archive · 2006 20 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

mdk ·

I've made a start on building a .tun file parser (the tuning file used by Albino, Vaz etc..)

You can get the schematic from here :

http://relivethefuture.com/music/patche ... Parser.osm

and theres a tuning file here for testing :

http://relivethefuture.com/music/patche ... ian_12.tun

The first concern is with the comment parsing, at the moment its very brittle, in that any minor changes in the source file can cause it to break.

A comment is basically any line with a ; at the start, but it might contain non alphanumeric chars, such as .

Im sure there must be a better way than my current set of sequence rules. <alphaNum*> <.*> <alphaNum*> I've tried to make a rule that says something like ; <alphaNum*> <newline> but that doesnt work.

My second problem is once i have the note -> frequency mapping contained in an array, how can i use it?

The midi->poly converter outputs a 'pitch' value but this is a stream and my array is all green data. So, is there a way in which i can get the midi note number, use that as the index to lookup in the array and use the resulting float value to control the frequency of an oscillator?

Any ideas or suggestions for either problem would be gratefully received..

infuzion ·

mdk wrote: My second problem is once i have the note -> frequency mapping contained in an array, how can i use it?

Not sure what you mean... can you provide an example that will allow us to play an OSC, or do you need help with that? cheers

mdk ·

let me describe things a bit more clearly.

After parsing the tuning file I have a Float Array which maps MIDI note numbers to frequencies in Hz.

What i have been trying is using the MIDI Split, I can get the note number, this is then used as the index into the Float Array Get At module, the output of is the frequency in Hz for that note, but its a green float signal.

I've not yet found a way to use this Hz value to control the frequency of say the sine oscillator.

a picture might help :

so this obviously doesnt work and im not quite sure how to make it work. I realise there is some magic that happens when you have a complete stream from midi in to mono out, but is there any way now to get it working.

any help would be great..

thanks. 🙂

jorge ·

Hi mdk

What you need to do is somehow connect the MidiToPoly to the white poly section. Because you dont need to affect it, you can just multiply any of the outputs of the MidiToPoly by zero ( leave the second input of the multiplier not connected ) and connect somewhere to the white section to the right.

Here's an example:

[old link]

mdk ·

cool..

the stupid thing is i already tried something like that and somehow it didnt work, now i did it again following your example..and it works..

now i can debug the file parser 🙂

thanks.

jorge ·

actually, I think it wont work properly, all notes will play the same frequency. The white section of the schematic represents poly sound and the frequency on the green component is used for all notes playing.

What you might need is a new component or event a FloatArray input to the MidiToPoly that accepts a table of 128 frequencies, one for each MidiNote. It would be very easy to implement.

Another way would be to write your table to a Mem component and use the MemRead component to access it using pitch to index it, I think that might be a better more flexible way.

stefan ·

Or write it into a graph and use graph to poly to read from it (with pitch for indexing)

jorge ·

stefan wrote: Or write it into a graph and use graph to poly to read from it (with pitch for indexing)

I thought that too, I was going to try it first in a schematic. I agree it's the best way at the moment.

Graph and FloatArray are suposed to be the same and will eventually converge and have the same connector symbol. Most component have been changed to support connecting a FloatArray to a Graph and vice-versa but not all of them.

mdk ·

right, thanks for the suggestions...

to make it more interesting i've realised that the .tun files dont contain a note number to frequency map, its actually a mapping of note numbers to fractional note numbers e.g.

note 10=1018 note 11=1088 note 12=1200 note 13=1271 note 14=1382

but for some reason the right hand side is multiplied by 100.

so i thought about using the midi event module to create a new event from the mapping but obviously midi only supports integer note numbers.

So if anyone has any bright ideas about how to use fractional note numbers im all ears.

One idea I have is to get the input note number and the mapped note number then find out the difference. Then use that difference to control the pitchbend amount to get the right frequency.

Also while im here, what range of values does the 'pitch' output of the midi->poly module use?

sambean ·

So if anyone has any bright ideas about how to use fractional note numbers im all ears.

How about dividing the number by 100, then using the pitch to frequency module?

so for 13 = 1271

divide by 100 = 12.71

which using the p to f gives me a frequency of 0.000754531

so multiplying by SR gives 34.0723 Hz

Would this work?

Sam

stefan ·

Pitch is iirc equal to note number. Which is great for you, because all you have to do then is use pitch as an index and use the value in your table as the new pitch, if you divide it by 100 that is 🙂

midi to poly pitch->graph to poly->multiply with 0.01->use as new pitch

mdk ·

right, well that sounds good but im a bit confused as to whats going on with the different frequency ranges (Hz / 0->1) and how im converting pitch to frequency.

here's a picture :

and the schematic :

http://relivethefuture.com/music/synthmaker/schematics/TunFileParser2.osm

and a different tuning file...the indian one in the first post is too far away from the normal western scale for audio debugging 🙂

http://relivethefuture.com/music/synthmaker/schematics/test.tun

:EDIT: So, at the moment im getting a really low frequency from the oscillator... :EDIT:

i can feel im really close but i just need to close the last gaps in my SM knowledge.

btw, i put the pitch index * 0.01 inside the parsing code so the pitch values should be correct coming out of the graph.

thanks again everyone for the help....hopefully soon i'll have a nice little module to share that makes it easy to add alternative tuning support to any SM creations. 😀

sambean ·

I can't seem to get anything out of the 'p to f' stream module, there may be a bug..

Try connecting it to an analyser then to a graph to float to read the value.. all I can get out is '1.#INF' regardless of the input, Anyone else get it to work?

rl ·

to make it work I had to insert a PolyToPolyInt between the MidiToPoly and the GraphToPoly

BTW: a guaranteed way to see a Windows NT BSOD is to insert an analyzer somewhere without breaking the stream path to the ASIO out.

mdk ·

😀 😀 😀

Hooray. Its working. thanks to everyone for helping out.

There's a completed schematic of my version here :

http://relivethefuture.com/music/synthmaker/schematics/TunFileTuner.osm

Now i think i'll look at using the scala .scl file format as well.

again, thanks to all of you, you're a helpful bunch around here. 🙂

sambean ·

Thanks you for sharing it with us!

No one need ever write a tuning module for their synths now..

Cheers

Sam

lalo ·

many thamx mdk 😀 phunktastik 🙂

Shifrin ·

Nice one, thanks very much 🙂

Shif.

mdk ·

dont get too excited yet 🙂

the parsing section still isnt bug free..

im trying to figure out a way to deal with the comments...

because some comments can even include the comment char itself e.g.

; This is a comment - and it has 'all sorts' of chars; in it.

i had some ideas but they just made the parser hang.

but i have a cunning plan which may just work. 😉

mdk ·

i followed the KISS - Keep It Simple Stupid, rule of programming and the file handling is much better. 🙂

Same link :

http://relivethefuture.com/music/synthm ... eTuner.osm

i've also made a little pack of .tun files for testing / playing with :

http://relivethefuture.com/music/synthm ... unpack.zip

enjoy. 🙂

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.