Script to convert wave files to Fathom's wavetable format

VST, AU, AAX, CLAP, etc. Plugin Virtual Instruments Discussion
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi all,

attached you can find a script that converts wav files to the wavetable format of the Fathom synthesizer. The wav files that are used as input have to meet the following conditions:
  • The file contains wav data and its extension is "wav".
  • The file is mono and is in 16 or 32 bit PCM format. So files in IEEE float format will not work!
  • If the file contains several cycles, i.e. if it is a "true" wavetable, then the number of samples must be a multiple of 2048 or the number given with the -l argument (see below).
If the files that you want to convert are in another format please use an audio editor, e.g. ocenaudio or Audacity, to first convert them to the aforementioned format before using them with the script.

The script takes the following arguments:

Code: Select all

  -f, --file: Converts a single file.
  -d, --dir: Recursively convert all files in the given directory.
  -g, --targetdir: Put all converted files into the given target directory. If
                   this parameter is not given and you convert a whole
                   directory then all files will be put next to the original
                   files.
  -l, --length: The number of samples in one cycle that's assumed for wave table files.
The following arguments can be used to set the meta data:

Code: Select all

  -c, --category: Use the given category for all converted files
  -a, --author: Use the given author for all converted files
  -m, --comment: Use the given comment for all converted files
  -r, --rating: Use the given rating (in [0, 10]) for all converted files
  -t, --type: Use the given type for all converted files
Examples
All examples given here assume that your system knows how to execute Python scripts, i.e. that the Python interpreter is in your path. If this is not the case you might have to prepend the commands with the full path to your Python interpreter, e.g.:

Code: Select all

C:\Path\To\Interpreter\python.exe FathomWTCreator.py -f Input.wav
Convert a single wavetable file. Because the -l parameter is not used one cycle is assumed to be 2048 samples long.

Code: Select all

FathomWTCreator.py -f Input.wav
Convert a wavetable file that contains cycles of length 1024 (example for some long arguments):

Code: Select all

FathomWTCreator.py --file=Input.wav --length=1024
Convert everything in directory "source" and write the converted files into the directory "converted":

Code: Select all

FathomWTCreator.py -d source -g converted
Convert everything in directory "source" and write the converted files next to the original files:

Code: Select all

FathomWTCreator.py -d source
Example usage for the meta data:

Code: Select all

FathomWTCreator.py -f "Input.wav" -c "A category" -a "Joe Doe" -m "A comment" -r 10
I hope some people find this script useful. Enjoy!

Kind regards,

BlitBit

Edit: Fixed some typos which mixed up the "-l" and "-t" parameter. Thanks to toonertik for making me aware of them!
You do not have the required permissions to view the files attached to this post.
Last edited by BlitBit on Thu Mar 15, 2018 9:42 pm, edited 1 time in total.
Passed 303 posts. Next stop: 808.

Post

That looks interesting... and thanks for sharing your work.
A few questions..
I have an old computer with Python 2.7, I think.. so question is.. what version is needed for the script?

In the intro you say quote>> "If the file contains several cycles, i.e. if it is a "true" wavetable, then the number of samples must be a multiple of 2048 or the number given with the -t argument (see below)"
In one of the code examples you have this quote" FathomWTCreator.py --file=Input.wav --length=1024" does this mean that this parameter overrides the default or am I missing something?
Finally, can you elaborate on the -t, --type argument please.

Thanks

Post

toonertik wrote:That looks interesting... and thanks for sharing your work.
A few questions..
I have an old computer with Python 2.7, I think.. so question is.. what version is needed for the script?
Yes, the script also works with Python 2.7. I have just tested it under Linux.
toonertik wrote: In the intro you say quote>> "If the file contains several cycles, i.e. if it is a "true" wavetable, then the number of samples must be a multiple of 2048 or the number given with the -t argument (see below)"
In one of the code examples you have this quote" FathomWTCreator.py --file=Input.wav --length=1024" does this mean that this parameter overrides the default or am I missing something?
Sorry, that was a typo that I have just fixed in the original post. It is meant to say "-l". The "-l" parameter overrides the default value of 2048 samples. It would for example be needed if you concatenated several of the AKWF waveforms in an audio editor. Each AKWF waveform consists of 600 samples so in this case you would use "-l 600".
toonertik wrote: Finally, can you elaborate on the -t, --type argument please.
The "-t" argument is a rather technical one, that's why I left it out. It influences the filenames that are created for the output files. For the conversion of the AKWF waveforms into Fathom's "Wave" format I have used the argument "-t Wave" which resulted in filenames like "AKWF 0001._._._.0.Wave.xml". If I hadn't used that parameter the result would have been "AKWF 0001._._._.0.Wave Table.xml" instead. See also the following comment towards the end of the script:

Code: Select all

# Comment this in if you only convert files with single waveforms and want to write a wave file
If you comment this line in (and comment the line with "writeWaveTableToXMLFile" out) then you also have to use the "-t Wave" option. I guess that's something that could definitively improved with the script.
Passed 303 posts. Next stop: 808.

Post

Thanks for reply... yes, on reflection I thought it might have been a typo...
Long time ago I used to do COBOL... damm keyboard and typos.. was never my fault or fat fingers..
I have quiet a few hand rolled single_cycles made over a number of years and of varying sample sizes..
When I get some time I will dig out old computer with python and run a few instances of the script with both my samples and the excellent AKWF's...
BTW, at the moment some of my hand rolled samples are of varying sample length that I used to use in the Emulator VSTi...
Converting them to "standard" sample Sngle_cycls is a PTIA... I have to resample with processing in either wavosaurus or SoundForge with a crude formula and get close.. then jiggle the rersampling to get say 2048 samples then resample without processing back to 44.1 (the standard I use).. just curious if you have a better method or script that does this?

Post

toonertik wrote:Thanks for reply... yes, on reflection I thought it might have been a typo...
Long time ago I used to do COBOL... damm keyboard and typos.. was never my fault or fat fingers..
Even with the much improved development tools of today I guess some things will never change. ;)
toonertik wrote: I have quiet a few hand rolled single_cycles made over a number of years and of varying sample sizes..
When I get some time I will dig out old computer with python and run a few instances of the script with both my samples and the excellent AKWF's...
BTW, at the moment some of my hand rolled samples are of varying sample length that I used to use in the Emulator VSTi...
Converting them to "standard" sample Sngle_cycls is a PTIA... I have to resample with processing in either wavosaurus or SoundForge with a crude formula and get close.. then jiggle the rersampling to get say 2048 samples then resample without processing back to 44.1 (the standard I use).. just curious if you have a better method or script that does this?
With regards to Fathom there is no need to resample the waves because it can deal with wavetables that contain samples of varying sizes all by itself. I have tested this by copying the data of a wave with 600 samples next to a wave with 2048 samples and could load the resulting wavetable into Fathom.

Perhaps I will extend the script with a mode where it creates a wavetable from all the waves found in a folder. It would work roughly as follows:
  1. Put all the waves that should go into the wavetable into a folder. The waves can be of different sizes.
  2. Name the waves so that they are sorted in the order in which they should appear in the wavetable.
  3. Run the script run in the alternative mode.
  4. Copy the resulting wavetable to the Fathom folder.
With regards to general resampling: this can be done with a small script that uses scipy.signal.resample at the cost of introducing additional dependencies.
Passed 303 posts. Next stop: 808.

Post

Thanks... I'll have a look at that soon.
I have just started a small project sampling some percussion instruments I have with another member, with a view to him creating SFZs, which is gonna take a few weeks.

Post Reply

Return to “Instruments”