Tool to load 8 bit samples from the Amiga era (IFF and RAW 8 bit signed mono PCM only)

Hi, as seen in this thread, I have started this tool to load 8 bit samples from the Amiga era (IFF and RAW 8 bit signed mono PCM only) in their original format:

Reviews and help are welcome, particularly on this part:

  • What is the proper way to convert a [-128, 127] int value to a [-1, 1] Lua float value? I’m dividing the int value by 128 and the result sounds right to me (at least exactly like loading the file from outside my tool), but is there a better way?
  • I’d like to be able to load files from my tool by right clicking them in the disk browser. I could add a menu item there, but I can’t access to the path of the file that was right clicked. Is it possible?

What it does

After installation, this tool adds a 8 bit sample loader > Load IFF or RAW file… menu entry to the Tools menu.

Clicking on it opens a file browser. Selecting an IFF or RAW 8 bit signed mono file will load it in the current instrument’s current sample :slight_smile:

For IFF files: sample rate, loop start info, and sample name are used if present. Octaves and compression are not supported (maybe a nice addition).

For RAW files: a sample rate of 16726 Hz is assumed (allow to customize this would be a nice addition).

Tip: try turning off interpolation in the sample options for that extra 8 bit noise. After that you can try a ~ 7 kHz low pass filter to tame some of it.

Note: this needs more tests at the moment.

If you want to try it you will need the files in their original format:

Samples I tested the IFF loader on:

  • st-01/strings6 = base sample and loop are clicky :frowning: (I need more checks on this part if you want to help)
  • st-02/fatbrass = no loop
  • st-02/guitar1 = uselessly looping?
  • st-17/Afterthought = nice loop :slight_smile:
  • st-17/badsample = a nice loop from Bad :slight_smile:
  • st-17/bass.drum = ends with a silent loop ?
  • st-17/brass1 = no loop
  • st-17/BrassEns.1 = no loop
  • st-17/Fantasy2 = nice loop :slight_smile:

The ST-17 directory looks like a good one to test IFF properties.

2 Likes

Another (sort of) possibility might be to use a file hook (although you may have to put an extension on the sample filenames):

--[[ 

file_import_hooks: Add support for new filetypes in Renoise. Registered file
types will show up in Renoise's disk browser and can also be loaded by drag and 
dropping the files onto the Renoise window. When adding hooks for files which
Renoise already supports, your tool's import functions will override the internal
import functions. 

Always load the file into the currently selected component, like 
'renoise.song().selected_track','selected_instrument','selected_sample'.

Preloading/prehearing sample files is not supported via tools.

The Lua table passed to 'add_file_import_hook' is defined as:

* Required fields:
  + ["category"] = in which disk browser category the file type shows up. 
      "song", "instrument", "effect chain", "effect preset", "modulation set", 
      "phrase", "sample" or "theme"
  + ["extensions"] = a list of strings, file extensions, that will invoke
      your hook, like for example {"txt", "swave"}
  + ["invoke"] = function that is called to do the import. return true when
      the import succeeded, else false.
]]

Find those calls further down this page https://files.renoise.com/xrnx/documentation/Renoise.ScriptingTool.API.lua.html

Why not create a raw file with say all 256 numbers from 0 to 255. Import raw into Renoise. Then use your own routine to import the same file. Compare the two samples (both graphically and numerically)? Personally I would’ve just stuck with divide 128. Even basic mathematics is ridiculously difficult :slight_smile:

2 Likes

You’re right, I tryed to do some stats, and I found this. If my lookup method is right, in the collection, they are:

  • 4662 iff files with a proper FORM header
  • 150 iff files without a FORM but with a VHDR chunk (probably useable)
  • 26 files with a BODY chunk but without a VHDR chunk. These could be loaded as raw file, without sample rate info.
1 Like

Uh huh. Also ST-29/xen-megablast (Xenon 2 Megablast?) has a small IFF BODY and text comment remnants a way through the file:

000028b0  26 3a 42 4a 44 34 1e 0a  00 06 16 26 34 34 2a 18  |&:BJD4.....&44*.|
000028c0  06 00 00 00 06 08 08 08  04 02 00 fc 6c 79 7a 65  |............lyze|
000028d0  72 20 56 31 2e 31 00 00  00 00 00 00 42 4f 44 59  |r V1.1......BODY|
000028e0  00 00 38 cc fc fc fa f2  ea e0 da d6 d8 d8 d8 d6  |..8.............|

And ST-29/xen-we:

00000c00  de e8 f6 fa fa fe 08 0e  0c 10 16 1a 0e fa fe 10  |................|
00000c10  10 08 06 18 38 42 3c 46  4c 50 58 3e 6c 79 7a 65  |....8B<FLPX>lyze|
00000c20  72 20 56 31 2e 31 00 00  00 00 00 00 42 4f 44 59  |r V1.1......BODY|
00000c30  00 00 35 3a 10 fe fa f0  e0 e2 ea f8 0a 16 16 04  |..5:............|
00000c40  fe 0e 04 e6 d6 e8 fc fc  fc 08 18 10 f4 e8 e8 f2  |................|

:slight_smile:

Thank you for the report, it helps :slight_smile:

I changed the tool to allow loading files with missing FORM tag:

  • Provided there is a ‘8SVX’ chain in the first 256 bytes, it will be considered an IFF audio file
  • It now finds the VHDR chunk, even in unusual positions (meaning “not the 13th byte”)

Two next easy step would be:

  • Allow loading files with a VHDR but no 8SVX tag
  • Allow loading files with only a BODY, skip the crappy header and load them with the raw file parser

With that I think it would load like 99% (?) of the files of the ST collection in their original format.

1 Like

Ok, i’ve done this:

  • Allow loading files with a VHDR but no 8SVX tag (only VHDR and BODY chunk are required to be considered an IFF 8SVX file)
  • When no VHDR is found in a file, it is considered a raw file (we have no sample rate info) but if an unexpected BODY chunk is found in this file, the tool will signal it to the user and ask if he wants to insert a slice marker at that position
  • Update to Renoise 3.2 (there is still a 3.1.1 branch if you need it)

If you are interested, more info about this project’s learnings and decisions are found in the doc folder

Next possible steps:

  • If the header of an IFF file is found in the middle of the file (unfortunately it is the case for a few files), read the sample rate but propose to either start after the BODY (skipping a large part of the file) or to use the whole file as data, marking the first body with a slice?
  • Allow to choose the sample rate for raw files?

Cheers!

1 Like