Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/wiki/supported_wav_formats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Supported WAV formats

Little Piggy Tracker loads samples as **16-bit PCM WAV** (`WAVE_FORMAT_PCM`,
compression code `1`). That is the format used by the classic tracker
sample pools and the one you should export to.

## What works

| Format | Compression code | Result |
|---------------------------------|------------------|-----------------------------------------|
| PCM 16-bit, mono | `1` | Full support |
| PCM 16-bit, stereo | `1` | Full support |
| PCM 16-bit with a `JUNK` chunk | `1` | Supported (the `JUNK` chunk is skipped) |
| PCM 8-bit, mono | `1` | Loads (expanded to 16-bit on load) |
| PCM 8-bit, stereo | `1` | Loads but the right channel is garbage |

## What is rejected

| Format | Compression code | Why |
|-------------------------|------------------|-------------------------------------------------|
| IEEE float (32-bit) | `3` | `Unsupported compression` — not PCM |
| ADPCM | `2` | `Unsupported compression` |
| µ-law / A-law | `6` / `7` | `Unsupported compression` |
| WAVE_FORMAT_EXTENSIBLE | `0xFFFE` | `Unsupported compression` — even if the sub-format is PCM |
| PCM 24-bit / 32-bit int | `1` | `Only 8/16 bit supported` |

## Common gotchas

- **WAVE_FORMAT_EXTENSIBLE** is what Windows exports when the "16-bit PCM"
option is picked from a save dialog. It looks like a normal 16-bit WAV
but carries compression code `0xFFFE` in the header, so the tracker
refuses it. Re-encode to plain PCM (`compression code 1`) to fix.
- **32-bit float** is the default export format of several DAWs and of
Audacity when "WAV (Float)" is selected. Export as WAV (PCM) 16-bit
instead.
- **24-bit** is common from audio interfaces. Not supported — convert.
- The `fmt ` chunk must declare exactly 8 or 16 bits per sample.

## Converting a WAV

With [sox](http://sox.sourceforge.net):

```sh
sox in.wav out.wav # re-encodes to the input format
sox in.wav -b 16 out.wav # force 16-bit (default PCM)
```

With Audacity: *File → Export Audio → File type: WAV (Microsoft) → Encoding:
Signed 16-bit PCM*.

## Where the parsing lives

The checks live in `WavFile::Open()`
(`sources/Application/Instruments/WavFile.cpp`):

- `comp != 1` → `"Unsupported compression"`
- `bitPerSample` not in `{8, 16}` → `"Only 8/16 bit supported"`
15 changes: 9 additions & 6 deletions sources/Application/Views/BaseClasses/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,26 @@ void View::drawMap() {
GUITextProperties props ;

//draw entire map
SetColor(CD_HILITE1) ;
char buffer[5] ;
props.invert_=true ;
//row1
SetColor(CD_ROW2);
props.invert_ = false ;
char buffer[5] ;
//row1
sprintf(buffer,"P G ");
DrawString(pos._x,pos._y,buffer,props) ;
pos._y++ ;
//row2
sprintf(buffer,"SCPI");
SetColor(CD_ROW);
sprintf(buffer,"SCPI");
DrawString(pos._x,pos._y,buffer,props) ;
pos._y++ ;
//row3
SetColor(CD_ROW2);
sprintf(buffer, " MTT");
DrawString(pos._x,pos._y,buffer,props) ;

//draw current screen on map
SetColor(CD_HILITE2) ;
SetColor(CD_CURSOR);
props.invert_ = true ;
pos._y = anchor._y;
switch(viewType_)
{
Expand Down
Loading