csoundlib - Utilities to work with csound

csoundlib - Utilities to work with csound#

csoundengine.csoundlib Module#

This module provides miscellaneous functionality for working with csound.

This functionality includes:

  • parse csound code

  • generate a .csd file

  • inspect the audio environment

  • query different paths used by csound

  • etc.

Functions#

audioBackends([available, platform])

Return a list of audio backends for the given platform

bestSampleEncodingForExtension(ext)

Given an extension, return the best sample encoding.

channelTypeFromValue(value)

Channel type (k, S, a) from value

compressionBitrateToQuality(bitrate[, format])

Convert a bitrate to a compression quality between 0-1, as passed to --vbr-quality

compressionQualityToBitrate(quality[, format])

Convert compression quality to bitrate

csoundOptionForSampleEncoding(encoding)

Returns the command-line option for the given sample encoding.

csoundOptionsForOutputFormat([fmt, encoding])

Returns the command-line options for the given format+encoding

csoundSubproc(args[, piped, wait])

Calls csound with given args in a subprocess, returns a subprocess.Popen object.

dumpAudioBackends()

Prints all available backends and their properties as a table

dumpAudioDevices([backend])

Print a list of audio devices for the given backend.

dumpAudioInfo([backend])

Dump information about audio backends and audio devices for the selected backend

ftsaveRead(path[, mode])

Read a file saved by ftsave, returns a list of tables

getAudioBackend([name])

Given the name of the backend, return the AudioBackend structure

getAudioBackendNames([available, platform])

Returns a list with the names of the audio backends for a given platform

getAudioDevices([backend])

Returns (indevices, outdevices), where each of these lists is an AudioDevice.

getDefaultAudioDevices([backend])

Returns the default audio devices for a given backend

getDefaultBackend()

Get the default active backend for platform

getNchnls([backend, outpattern, inpattern, ...])

Get the default number of channels for a given device

getSamplerateForBackend([backend])

Returns the samplerate reported by the given backend

getSystemSr(backend)

Get the system samplerate for a given backend

getVersion([useApi])

Returns the csound version as tuple (major, minor, patch)

highlightCsoundOrc(code[, theme])

Converts csound code to html with syntax highlighting

instrNames(instrdef)

Returns the list of names/instrument numbers in the instrument definition.

instrParseBody(body)

Parses the body of an instrument, returns pfields used, output channels, etc.

isPfield(name)

Is name a pfield?

joinCsd(orc[, sco, options])

Joins an orc and a score (both as str), returns a csd as string

lastAssignmentToVariable(varname, lines)

Line of the last assignment to a variable

locateDocstring(lines)

Locate the docstring in this instr code

makeIncludeLine(include)

Given a path, creates the #include directive

midiDevices([backend])

Returns input and output midi devices for the given backend

mincer(sndfile, outfile, timecurve, pitchcurve)

Stretch/Pitchshift a output using csound's mincer opcode (offline)

nextpow2(n)

Returns the power of 2 higher or equal than n

normalizeInstrumentName(name)

Transform name so that it can be accepted as an instrument name

normalizePlatform(s)

Return the platform as given by sys.platform

opcodesList([cached, opcodedir])

Return a list of the opcodes present

parseOrc(code[, keepComments])

Parse orchestra code into blocks

parseScore(sco)

Parse a score given as string, returns a data.

recInstr(body, events[, init, outfile, sr, ...])

Record one instrument for a given duration

runCsd(csdfile[, outdev, indev, backend, ...])

Run the given .csd as a csound subprocess

saveAsGen23(data, outfile[, fmt, header])

Saves the data to a gen23 table

saveMatrixAsGen23(outfile, mtx[, extradata, ...])

Save a numpy 2D array as gen23

saveMatrixAsMtx(outfile, data[, metadata, ...])

Save data in wav format using the mtx extension

soundfontIndex(sfpath)

Make a SoundFontIndex for the given soundfont

soundfontInstrument(sfpath, name)

Get the instrument number from a preset

soundfontInstruments(sfpath)

Get instruments for a soundfont

soundfontPresets(sfpath)

Get presets from a soundfont

soundfontSelectPreset(sfpath)

Select a preset from a soundfont interactively

splitDocstring(body)

rtype:

tuple[str, str]

splitInclude(line)

Given an include line it splits the include path

testCsound([dur, nchnls, backend, device, ...])

Test the current csound installation for realtime output

userPluginsFolder([float64, apiversion])

Returns the user plugins folder for this platform

Classes#

Any(*args, **kwargs)

Special type indicating an unconstrained type.

AudioBackend(name[, alwaysAvailable, ...])

Holds information about a csound audio backend

AudioDevice(id, name, kind[, index, numchannels])

An AudioDevice holds information about a an audio device for a given backend

Csd([sr, ksmps, nchnls, a4, options, ...])

Build a csound script by adding global code, instruments, score events, etc.

CsoundProc(proc, backend, outdev, sr, nchnls)

A CsoundProc wraps a running csound subprocess

MidiDevice(deviceid, name[, kind])

A MidiDevice holds information about a midi device for a given backend

ParsedBlock(kind, text, startLine[, ...])

A ParsedBlock represents a block (an instr, an opcode, etc) in an orchestra

ParsedInstrBody(pfieldIndexToName, ...[, ...])

The result of parsing the body of an instrument

ScoreLine(kind, p1, start, dur, args)

An event line in the score (an instrument, a table declaration, etc.)

SoundFontIndex(soundfont)

Creates an index of presets for a given soundfont

TableDataFile(tabnum, data, fmt[, start, ...])

A table holding either the data or a file to the data

runonce(func)

To be used as decorator.