Skip to main content

ezsampler

ezsampler(
@pitch 6000
@duration 2000
@velocity 64
@keymap null
@resample 1
@useseed 0
@usecache 1
) -> llll

Generates a buffer given pitch, duration, and velocity values, and an optional list representing a sampler key map. The key map must be a list of key-value pairs, where the each key is a numeric pitch value, in midicents, that maps to one or more audio file paths corresponding to that pitch, or to a list of key-value pairs with velocity values, between 0 and 127, as keys, and audio file paths as values. When multiple file paths are provided for a given pitch or velocity key, one of them is chosen at random. If no keymap is provided, the function defaults to a basic, built-in key map. The generated buffer will be one that best approximates the specified pitch, duration, and velocity values.


Arguments

  • @pitch [int/float]: target pitch in midicents. (default: 6000).
  • @duration [int/float]: target duration in milliseconds. Set to null to get the sample's max. duration. (default: 2000).
  • @velocity [int/float]: target velocity, from 0 to 127. Used only when keymap has velocity-based options. (default: 64).
  • @keymap [llll]: key mapping, with pitch in midicents as key and file path as value (default: null).
  • @resample [int]: resample buffer to match target pitch. (default: 1).
    • 0: off
    • 1: on
  • @useseed [int]: use seed-based random selection function. (default: 0).
    • 0: off
    • 1: on
  • @usecache [int]: use buffer cache to optimize memory usage. (default: 1).
    • 0: off
    • 1: on

Output

buffer [llll]


Usage

$chord = c5 e5 g5 b5;
$keymap = [6900 'viola.wav'];
for $pitch in $chord do (
ezsampler(
@pitch $pitch
@keymap $keymap
@duration 6500
).transcribe()
);
render(@play 1)