Skip to content

pcmconv

A collection of utilities for importing and converting samples. At the moment, two converters are available, for PWM samples (commonly used for drums in 1-bit engines) and raw PCM with arbitrary resolution (bit depth).

Graphical Interface

The graphical interface of this plugin consists of a single dialog, which you can find in the main menu, under Generate -> Import .wav. You must have an open module, and your cursor or selection must be on a suitable block field. Suitable fields will typically represent some type of sample values, though any field of type int or uint will do.

  • File - The name a PCM .wav file to import. Use the Browse button to search your file system.
  • Use Channel - Which channel to import from stereo samples.
  • Target - The type of sample to convert to.
  • Sample Rate - The target sample rate of the converted sample. Must be an integer.
  • Resolution - The target bit depth of the converted sample.
  • Signedness (PCM only) - Either signed or unsigned, depending on how the values of the converted sample should be interpreted.
  • Threshold (PWM only) - The threshold at which the PWM converter should trigger a state flip. Must be a floating point value between 0 and 1. Increase the threshold if the imported sample is too noisy.
  • Paste Mode - How the sample data should be pasted at the target location.

pcmconv will automatically guess suitable values for all the settings (except the threshold for PWM import). In most cases you will just need to select a .wav file to import.

Key Bindings

You can set keyboard shortcuts for the pcmconv dialog by adding the following code to your config/config.scm:

(bind-keys! 'plugins '<KEY-SPEC> 'pcmconv)

API

[procedure] (pcmconv::audio->pcm AUDIO #!key BITS SIGN)

Convert the first channel of the md-audio struct AUDIO into raw pulse-coded wave data. BITS denotes the resolution of the output samples in bits (defaults to 8), and SIGN may be either 'signed or 'unsigned, to determine if the output values are signed or unsigned (defaults to 'unsigned).

[procedure] (pcmconv::audio->pwm AUDIO #!key BITS THRESHOLD INPUT-LENGTH)

Converts the first channel of the md-audio struct AUDIO into raw pulse-width wave data. BITS denotes the resolution of the output values in bits (defaults to 8), THRESHOLD sets the threshold at which the converter will assume a state flip (must be an inexact value between 0 and 1, defaults to 0.1), and INPUT-LENGTH denotes the number of samples to use from the input audio data (defaults to the length of the input audio data).