xiphonics / picoTracker

BSD 3-Clause "New" or "Revised" License
212 stars 18 forks source link

Add Script / Documentation on converting samples to a supported format. #208

Open simotek opened 4 months ago

simotek commented 4 months ago

I have tried a number of methods to convert samples into a format that will work on the picotracker. The most conservative was sox -S "$SAMPLE_DIR/$SAMPLE_PATH" -r 22050 -b 16 -c 1 -e unsigned-integer "samplelib/$SAMPLE_FOLDER/$SAMPLE_OUT.wav" with both the unsigned and signed 16 bit integer versions not working there are some samples at http://simotek.net/downloads/BassU22/

I have also tried using ffmpeg with no luck. So far i've found very few samples that will work out of the box.

maks commented 4 months ago

Thanks for reporting this @simotek 👍🏻 Definitely do need to document specifically what sample file formats are supported. I think @democloid is planning to work on this soon.

simotek commented 4 months ago

I also tried signed versions with

maks commented 4 months ago

so starting from this line, the code here is the source of truth on what wav file formats are supported.

Having a look at the code, it supports:

But interesting things to note:

  1. number of channels is used but never actually validated to be 1 or 2
  2. sample rate is stored and then used to adjust playback rate (see SampleInstrument 187)
  3. theres 3 magic number checks of various parts of the file metadata header, I'll need to look up what each of those parts of the header contain that they are checking

I'll try to break this code out into a little harness and then run tests on arm emu against various sample files to see if theres also possibly any bugs in that code, possibly due to endianess differences.

simotek commented 3 months ago

Interestingly the samples work fine with LGPT

maks commented 3 months ago

Interestingly the samples work fine with LGPT

@simotek VWould you know which version of LGPT you were using that worked? That would help with cross checking it's source with pT's to see what the difference is.

peterswimm commented 3 months ago

the things that would make legacy piggy barf the most is metadata in the wav header

democloid commented 2 months ago

@simotek As frustrating as this may sound, the problem you're having is not related to format, but with spaces on the filenames. I'm annoyed at not having looked at this earlier to identify the issue.

That said, wav files don't seem to support any arbitrary combination of int format and endianness. What's supported in wav, and picoTracker as well is: unsigned 8 bit signed 16 bit little endian 1 or 2 channels Any sample rate up to 44100Hz

I have tested all these combinations and there seems to be no problems importing any file like this.

That said, I have identified some other issues: Playback:

File system:

Most of the file system issues should be addressed by a new implementation we've been working on. The playback issues I have to work on. We also need better feedback to the user when encountering an invalid file.