Tune Smithy => Wish List => Topic started by: DanieLionius on June 18, 2010, 09:53:33 PM

Forum for Tune Smithy, Bounce Metronome and other software from Robert Inventor

Title: Ability to retune soundfont files in FTS
Post by: DanieLionius on June 18, 2010, 09:53:33 PM
G'day Robert,

Just thought I'd open a new post on this exciting topic. I do believe being able to automate the process of retuning whole soundfont banks is probably a long way off. However I'll try the way you suggested, and let you know how it goes. What will be intersting to see is whether the fine tuning adjustments in viena will make a difference to the overall process. But I'll try it and see.

I know you are busy with your other program, so thanks for taking the time to help with this. The thing with soundfonts is that I will need to get permission to change them. So pending on that, I'll upload a few finished instruments to you.


Title: Re: Ability to retune soundfont files in FTS
Post by: DanieLionius on June 19, 2010, 04:39:33 AM
Well it works. I export the WAVs from Viena, analyse them with FTS, calc and change the sample rate in WinHex, open GoldWave and save file and re-analyse with FTS and the result is accurate to within 100th-1000th of a Hertz! A very, very, good preliminary result.

However after importing them back into Viena and overwriting the samples, saving, and playing the synth and analysing some recordings, the ET samples are out of tune by 0.2 - 0.8 cent.

I am loading the sndfont onto my Audigy 2 card and playing it as a device in a sequencer (xgworks). I suspect the problem is in Viena somewhere but I have already deleyed all the fine and course tuning offsets in the program and it hasn't fixed the problem.

I might just have to muck around a bit until i can pinpoint the problem. Or try the same process in Creative Vienna.

The sndfnt I am using is General_User_GS and I have so far just retuned the Synth Bass 2 voice.

Unfortunately I can't upload it to you (the forum has a limit of 10Mb) unless I use an upload site?....

On a side not: After a discussion with Jeff Scott, he was saying that when tuning it is usually a trade off between all the partials to put a note in tune, instead of just by the fundamental. In other words you would probably work out the average result of all your partials. (finding the fundamental of each and getting the average). Have you any thoughts on this approach?



Title: Re: Ability to retune soundfont files in FTS
Post by: Robert Walker on June 19, 2010, 07:04:01 AM
Great, glad it works. I think I know why you got the slight difference in pitch measurements when the samples were played back. At least, it is a possible cause that would have that effect.


First thought on this - probably because the pitch varies slightly through the sample, attack of the note may be at a slightly different pitch from the looped section.

So if the attack is long and looped section is short then when you analyse the sample the analysed pitch is mainly the pitch of the attack (or may be a mixture of the two).

While if you analyse the note played back in your soundcard it is mainly the pitch of the looped section.


You can test that by using FTS to analyse the looped section of the sample only. Or trim your recordings so that they are the same length as the sample - i.e. same number of samples.

You could also try playing the soundfont in SynFont and see if you get the same pitch you got with the soundcard.


The attack part of the note may colour perception of the rest of the note, so it may be something of an artistic judgement what you use for the analysis. But if the aim is to get "beatless chords" for long sustained notes then the looped section is the most important part.

Suggests that maybe when you analyse the frequency of the note it would be best to analyse the looped section only.

Which is a bit fiddly because you need to check where the loop points are and then trim to those before analysing. Again an auto retuning soundfont analysing program could just extract the loop points from the sound font when it extracts the sample and use those for the analysis.


Title: Re: Ability to retune soundfont files in FTS
Post by: Robert Walker on June 19, 2010, 09:24:21 AM
Yes re Jeff Scott's remark - then you can use the "Add harmonics analysis" options.

Should be a good approach for harmonic or slightly inharmonic timbres. For moderately inharmonic timbres like piano or very inharmonic ones like bells however, you'd need to use the fundamental or the second harmonic. Well - or you can just set a limit on how far away the piartials can be to count as "in tune" and use the average of all the ones that are close enough to the harmonic series to count.

The  "Add harmonics analysis" does something like that though I can't remember the details of what it does now - will look into that later on when I work on this in detail.


This works out the pitch based on an averaging over all the partials to improve the accuracy of the pitch measurement.


This averaging will only work for harmonic timbres or very slightly inharmonic ones. With inharmonic instruments like bells, then you may be best off using just the fundamental, or if it is missing its fundamental, the second partial (first harmonic).

With piano particularly, which is moderately inharmonic with the partials getting gradually sharper as you go up the harmonic series, then it is an artistic judgement about how to stretch it, but in any case you wouldn't use the average of all the partials here either. You probably use the fundamental and then if you decide to stretch the octaves, do it in a way that depends in some way on the amount of inharmonicity in the tone of the particular piano sample.

Here are some links:

Piano tuning - stretched octaves (

Inharmonicity - Pianos (

Iharmonicity and piano size (

So anyway - if doing it automatically best thing for piano and for any inharmonic timbre is to just use the fundamental. For the piano you could have a "stretched octaves" option with some way of auto detecting the amount of stretch from the timbre, or let user customize it.

That stretched octaves option would involve making new samples at least for every octave and probably more often than that - though they could all be based on the original sample retuned by varying its sample rate if the original instrument doesn't have as many samples as that.

Title: Re: Ability to retune soundfont files in FTS
Post by: Robert Walker on June 19, 2010, 09:46:19 AM
Sorry about the upload limit.

I've increased the upload maximum file size to 200 MB.

But seems to have a time out as well and though I've increased the timeout parameters for php scripts, it still times out after just a minute or two.

I don't know what the reason is, if it is an issue with my browser, or the server or what it is. Also this forum doesn't have an option to show a progress meter for the upload so if it fails you only know when you get a rather uninformative time out message. Sorry about that.

Probably is some other gadget I can add to the web space to do this -  or I can add a special ftp upload area for the forum. Will look into it

BTW this is a public forum, the messages and any attachments are publicly viewable.

So you should only upload things here which you are happy for anyone in the world to download if they so decid. If you want to send me something privately, use my e-mail address.



Title: Re: Ability to retune soundfont files in FTS
Post by: DanieLionius on June 20, 2010, 03:56:14 AM
Thanks for all that feedback.

It seems I'm so close butcan not work out why these different synths are playing back at different pitches. The SyFonOne player now is palying everything in ET sharp by about 17 cents! But the relative pitch is good, to within 1 cent. It should actually be to 1,000th of a cent; as I've told you, analysis of the wave after saving in GoldWave yields an accuracy to ET of 100-1,000th of a Hz! That's why I can't work out why when I play one of those very same pitches with the keyboard it is sometimes out by within a cent, or even 17 cents. And I am not going through FTS, just either my Creative card or SyFonOne respectively. I might try the sfz+ player next..........

Could it have something to do with the way the synth reads the sample rates? Again I doubt it, the General_User_GS font already has samples of varying sample rates, and curiously not the usual multiples of 44100; things like 44300, 44211 - whatever!

I will say in playing back the font on the keyboard I was impressed with the tuning; I thought I'd made it!
And with through the Creative soundcard the pitches vary only by no more than a cent (0.9 was largest I think).

There is a feature in Viena to play the sample and with the loop button depressed, just loop the sample indefinitely. I might try recording these, and also the sound of the on screen keyboard in Viena - make sure Viena is doing it's job!

So while I should be studying for my last exam, I feel so close to having gotten a real impressive pitch resolution here; the results are already fairly ear-impressive!

BTW: Why when in 'Notes in Play' do the pitch bends show as large numbers i.e 8192, 7490, 8045 etc. when they should all be low numbers for a Just scale as in 0, maybe 125, -450, 256 etc?

Getting back, I will also try the Timidity player as this handles soundfonts differently, although can not be played in real-time with a keyboard.

What do you think of the change of sample rate trick, and the analysis results? Very impressive and conclusive for all the samples, hey?

Here are the soundfonts, the original and edit (Look below):

Again at your leisure,

Nope that 60Mb soundfiont still won't upload...... timed out oh well


Title: Re: Ability to retune soundfont files in FTS
Post by: Robert Walker on June 20, 2010, 07:49:18 AM

Just a thought - if you feel you should be studying for your final exam, why not leave this project until after they are over? I know how tantalising it can be when you have nearly managed to get something done - same thing often happens to me when coding.

But the project won't go away, if you set it to one side for a few days or weeks or whatever, you will be able to return to all this after your exam is over.

Often when you come back to something after a break you get new insights, or faster ways of doing things. Also I might have done more programming by then or may have more time to work on it.

Anyway that's just a thought, I don't want to tell you what to do :).

But, just to say, from my part anyway, if you want to forget all about this for a few days or weeks that's fine as far as I'm concerned and we can take up this dialog again whenever you are ready.


Yes those sorts of sample rates suggest that perhaps the designer of the font has already used the same trick to retune the sound font samples. It's not an original idea, I read about it somewhere years ago, just can't remember where I saw it.

For the Notes in Play - the pitch bend there is the actual number sent via midi to retune the notes. The 8192 according to the midi spec is what you send for 0 pitch bend. So to get the numbers you expect just subtract 8192. I could add a check box to do that to that window, when I revise it.

If you find the soundfont is just a bit out of tune - I'm assuming it is out by the same amount for all the notes that use the sample - then one idea is to do it recursively - find out the pitch again when played back in Creative. Suppose you find it is 0.9 cents sharp. Then go back to the sample and retune it flat by an extra 0.9 cents. Then play it back in Creative again, find the pitch, adjust the sample for the soundfont again, and repeat and see if you get closer and closer to the desired pitch by doing that. Or might give more information to help locate what the issue is.

And it will probably help to remove the attack whenever you do the analysis otherewise the analysed pitch will depend on the length of the note.

I don't know why you'd get those particular issues with the pitch not quite as expected. One wonders if it is a clock issue, but that seems a bit unlikely, surely the clocks on soundcards are much more accurate than this. Or some kind of software issue. I don't have any ideas about it yet. I wonder if e.g. the designer of SynFont would have any ideas especially about why his software is playing the same soundfont at a different pitch from the Creative card and whether it is a software or hardware issue or what it is.

Anyway - please don't feel you have to reply to this post any time soon if you feel you'd be better studying for your last exam :-).

Good luck, thanks,


Title: Re: Ability to retune soundfont files in FTS
Post by: DanieLionius on October 03, 2010, 09:36:56 PM
:) G'day Robert,

Well, it's been a while. You'll be glad to know I did well at my study - got through the exams.
I have pretty much given up on tuning the XG synths because they only have a resolution of about 1.3 cents.
So now, as far as music is concerned I have finished my guitar drawings and have some engineers looking at them. As for synths, I think probably I should move onto samplers and look closely how waveforms can be generated to define pitch and timbre etc.........

As for sampling, the first go I had was creating a soundfont. I realised the problem I had with the Creative card is that the Soundfont player only has a resolution of about 1.5 cents. So I went back to the samples and retuned them using the trick you showed me to change the sample rate, using WinHex etc. This works really well, and shows me that the pitch detection in Analyse Task in Tune Smithy is doing something right, because when I analyse the sample and then change the sample rate the detection is within 0.02 of a cent every time! So I created a nylon string guitar bank which you can check out if you wish below.
 Unfortunately there are some problems: When I use the Soundfont Synth on the card to play back a sample in the bank, I record this and then analyse it but unfortunately the pitches vary between 0.1 - 0.7 cent. I realized this could be any number of things: the velocity curve actually has an effect on pitch, the audigy card is not playing the sample back correctly; the audigy card could be a wavetable player, thus limited in ability to read samples; the soundfont is not correctly set up: a change in the attack or decay time could affect the overall pitch reading; Tune Smithy is counting waves over time, therefore the time and any vacant space in the recording might effect the result???; and the list goes on.

Still, I believe I'm making progress. The font below demonstrates that in the C4-C5 range the pitch for a just C scale is good to about 0.3 cent. So a few things need to happen in order for me to make this work…..

1)   Will need to understand pitch detection, and use best method where possible.
2)   Need to understand how the amplitude envelope affects pitch, and the best place to take a pitch reading.
3)   Need to create the best loop points in original sample, which because of stupid bit and sampling rates, keep causing glitches in my sound (is it possible to ever get these right?).
4)   The analysis should be predominately be done on the sustain portion of the note and/or the loop.
5)   Make sure sample player is playing back the sample exactly as-is!
6)   An automated process of retuning would really help, i.e. have a sample analysed, looped and ready to go; define it’s pitch range; generate the sample rates for that scale in spreadsheet (done); output file names and sample rates (in .csv format); run as script into wave editor and generate .wavs; import into sample (Vienna) and define ranges.
So, it’s plain to see it’s a lot of work to make a sound bank! I guess where you could help if possible is in letting me do a batch process of analysing pitch and then outputting the fundamental pitches into a format that can be imported into spreadsheet (say excel, .csv). Then the sheet will apply sample rate retunes to file names which can be run through a file editor (I don’t know how to do this yet, WinHex?). That will take care of most of the work.

Oh! I haven’t dismissed Tune Smithy as a Midi interface (it would be really awesome with a continuous pitch wheel, such as an analogue synth) and is great for generating preset scales and midi files.

Look forward to your knowledgeable advice and ideas,

Daniel Luke Ivkovic.

Title: Re: Ability to retune soundfont files in FTS
Post by: DanieLionius on October 03, 2010, 10:17:24 PM
Nylon String Guitar Bank Soundfont (tuned to Just Intonation C Ionian), (work in progress).

Title: Re: Ability to retune soundfont files in FTS
Post by: Robert Walker on October 05, 2010, 09:08:59 AM
Glad to hear your exams went well.

I'm pretty busy again right now but will look into the batch processing when I have a bit of time to work on FTS again.

One idea is to do a soundfont for twelve equal. I know you are interested in just intonation - but if you make it twelve equal, then with pitch bends you can retune it to whatever tuning you like. Much more flexible, and you would then be able to use it with Tune Smithy.

Even with just intonation, any just intonation twelve equal key will only work for some chords, as I expect you know. E.g. with a C major scale just intonation you can't have the C G D A E fifths all pure and also have the C to E interval a pure 5/4, (because of course the fifths make it an 81/64 instead) so one or the other has to be sacrificed. Normally since the aim is to be able to play at least some pure 5/4 thirds, you make it so the A to E is no longer a pure fifth.

But if you tune it accurately to twelve equal and then play it through e.g. FTS then you can play any just intonation scale and any other tuning you like.

Of course - depending on the pitch bend accuracy of whatever you use to play the sound font.

If your soundcard font player isn't accurate enough, I wonder if software may do it better.

Did you try SyFonOne? (

I haven't tested it for pitch accuracy yet, so don't know how good it is but might be worth a try, might solve the problem.

Yes indeed, the attack and decay will surely affect the pitch measurement. With a long sustain and measuring it on the sustain then you would expect more consistent measurements. Also if beats are the main thing you are interested in i.e. to play beatless just intonation chords, then the sustained part of the note is what matters most as that is the part that is playing when you hear the beats.

With the hex editing trick, then you should be able to retain the original loop points as you don't need to edit the sample at all except to vary the number near the head of the file to specify the intended frequency. Though the original loop points might still cause artefacts depending on how careful the soundfont designer was.

Sorry can't really help there as I haven't tried varying the loop points of samples in sound fonts myself, and never made my own soundfont.

This is just a quick post as I'm in the middle of complicated coding and debugging for Bounce Metronome Pro and the FTS Lambdoma software right now.

Will take a look at what you've done and have a look at the batch processing possibilities in FTS 3 when I have a bit more time.