csnd

package module
v0.0.0-...-6fc0d77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2019 License: LGPL-2.1 Imports: 5 Imported by: 0

README

Go Binding for Csound

This wrapper is still very experimental. It has been tested only on Linux. It needs a proper installation of Csound with header files in the include path in the csound directory (e.g. csound/csound.h). libcsound64 has to be in the PATH.

You can install this package with go get:

go get github.com/fggp/go-csnd

Or you can download a zip archive of the project using the 'Download ZIP' button on the right. You'll get a zip file named 'go-csnd-master.zip'. Decompressing it you'll get a directory named 'go-csnd-master'. Rename this directory to 'go-csnd' and move it to '$GOPATH/src/github/fggp'. Enter into the '$GOPATH/src/github/fggp/go-csnd' directory. You can eventually adapt the #cgo directives in csnd.go to your system. Finally install the package with go install.

This wrapper is intended to be used with a double build of Csound.

Documentation

Overview

GO Bindings for Csound

This wrapper is still very experimental. It has been tested only on Linux. It needs a proper installation of Csound with header files in the include path in the csound directory (e.g. csound/csound.h). libcsound64 have to be in the PATH.

You can install this package with go get:

go get github.com/fggp/go-csnd

Or you can download a zip archive of the project using the 'Download ZIP' button on the right. You'll get a zip file named 'go-csnd-master.zip'. Decompressing it you'll get a directory named 'go-csnd-master'. Rename this directory to 'go-csnd' and move it to '$GOPATH/src/github/fggp'. Enter into the '$GOPATH/src/github/fggp/go-csnd' directory. You can eventually adapt the #cgo directives in csnd.go to your system. Finally install the package with `go install`.

This wrapper is intended to be used with a double build of Csound.

Use examples can be seen here: https://github.com/kunstmusik/csoundAPI_examples/tree/master/go

Index

Constants

View Source
const (
	CSOUND_SUCCESS        = 0  // Completed successfully.
	CSOUND_ERROR          = -1 // Unspecified failure.
	CSOUND_INITIALIZATION = -2 // Failed during initialization.
	CSOUND_PERFORMANCE    = -3 // Failed during performance.
	CSOUND_MEMORY         = -4 // Failed to allocate requested memory.
	CSOUND_SIGNAL         = -5 // Termination requested by SIGINT or SIGTERM.
)

Error Definitions

View Source
const (
	CSOUNDINIT_NO_SIGNAL_HANDLER = 1
	CSOUNDINIT_NO_ATEXIT         = 2
)

Flags for csoundInitialize().

View Source
const (
	// This should only be used internally by the original FileOpen()
	// API call or for temp files written with <CsFileB>
	CSFTYPE_UNKNOWN = iota

	CSFTYPE_UNIFIED_CSD // Unified Csound document
	CSFTYPE_ORCHESTRA   // the primary orc file (may be temporary)
	CSFTYPE_SCORE       // the primary sco file (may be temporary)
	// or any additional score opened by Cscore
	CSFTYPE_ORC_INCLUDE   // a file #included by the orchestra
	CSFTYPE_SCO_INCLUDE   // a file #included by the score
	CSFTYPE_SCORE_OUT     // used for score.srt score.xtr cscore.out
	CSFTYPE_SCOT          // Scot score input format
	CSFTYPE_OPTIONS       // for .csoundrc and -@ flag
	CSFTYPE_EXTRACT_PARMS // extraction file specified by -x

	// audio file types that Csound can write (10-19) or read
	CSFTYPE_RAW_AUDIO
	CSFTYPE_IRCAM
	CSFTYPE_AIFF
	CSFTYPE_AIFC
	CSFTYPE_WAVE
	CSFTYPE_AU
	CSFTYPE_SD2
	CSFTYPE_W64
	CSFTYPE_WAVEX
	CSFTYPE_FLAC
	CSFTYPE_CAF
	CSFTYPE_WVE
	CSFTYPE_OGG
	CSFTYPE_MPC2K
	CSFTYPE_RF64
	CSFTYPE_AVR
	CSFTYPE_HTK
	CSFTYPE_MAT4
	CSFTYPE_MAT5
	CSFTYPE_NIST
	CSFTYPE_PAF
	CSFTYPE_PVF
	CSFTYPE_SDS
	CSFTYPE_SVX
	CSFTYPE_VOC
	CSFTYPE_XI
	CSFTYPE_UNKNOWN_AUDIO // used when opening audio file for reading

	// miscellaneous music formats
	CSFTYPE_SOUNDFONT
	CSFTYPE_STD_MIDI   // Standard MIDI file
	CSFTYPE_MIDI_SYSEX // Raw MIDI codes eg. SysEx dump

	// analysis formats
	CSFTYPE_HETRO
	CSFTYPE_HETROT
	CSFTYPE_PVC   // original PVOC format
	CSFTYPE_PVCEX // PVOC-EX format
	CSFTYPE_CVANAL
	CSFTYPE_LPC
	CSFTYPE_ATS
	CSFTYPE_LORIS
	CSFTYPE_SDIF
	CSFTYPE_HRTF

	// Types for plugins and the files they read/write
	CSFTYPE_UNUSED
	CSFTYPE_LADSPA_PLUGIN
	CSFTYPE_SNAPSHOT

	// Special formats for Csound ftables or scanned synthesis
	// matrices with header info
	CSFTYPE_FTABLES_TEXT   // for ftsave and ftload
	CSFTYPE_FTABLES_BINARY // for ftsave and ftload
	CSFTYPE_XSCANU_MATRIX  // for xscanu opcode

	// These are for raw lists of numbers without header info
	CSFTYPE_FLOATS_TEXT    // used by GEN23 GEN28 dumpk readk
	CSFTYPE_FLOATS_BINARY  // used by dumpk readk etc.
	CSFTYPE_INTEGER_TEXT   // used by dumpk readk etc.
	CSFTYPE_INTEGER_BINARY // used by dumpk readk etc.

	// image file formats
	CSFTYPE_IMAGE_PNG

	// For files that don't match any of the above
	CSFTYPE_POSTSCRIPT  // EPS format used by graphs
	CSFTYPE_SCRIPT_TEXT // executable script files (eg. Python)
	CSFTYPE_OTHER_TEXT
	CSFTYPE_OTHER_BINARY
)
View Source
const (
	CSOUND_CONTROL_CHANNEL   = 1
	CSOUND_AUDIO_CHANNEL     = 2
	CSOUND_STRING_CHANNEL    = 3
	CSOUND_PVS_CHANNEL       = 4
	CSOUND_VAR_CHANNEL       = 5
	CSOUND_CHANNEL_TYPE_MASK = 15
	CSOUND_INPUT_CHANNEL     = 16
	CSOUND_OUTPUT_CHANNEL    = 32
)

Constants used by the bus interface (csoundGetChannelPtr() etc.).

View Source
const (
	CSOUND_CONTROL_CHANNEL_NO_HINTS = 0
	CSOUND_CONTROL_CHANNEL_INT      = 1
	CSOUND_CONTROL_CHANNEL_LIN      = 2
	CSOUND_CONTROL_CHANNEL_EXP      = 3
)
View Source
const (
	// message types (only one can be specified)
	CSOUNDMSG_DEFAULT  = 0x0000 // standard message
	CSOUNDMSG_ERROR    = 0x1000 // error message (initerror, perferror, etc.)
	CSOUNDMSG_ORCH     = 0x2000 // orchestra opcodes (e.g. printks)
	CSOUNDMSG_REALTIME = 0x3000 // for progress display and heartbeat characters
	CSOUNDMSG_WARNING  = 0x4000 // warning messages

	// format attributes (colors etc., use the bitwise OR of any of these:
	CSOUNDMSG_FG_BLACK   = 0x0100
	CSOUNDMSG_FG_RED     = 0x0101
	CSOUNDMSG_FG_GREEN   = 0x0102
	CSOUNDMSG_FG_YELLOW  = 0x0103
	CSOUNDMSG_FG_BLUE    = 0x0104
	CSOUNDMSG_FG_MAGENTA = 0x0105
	CSOUNDMSG_FG_CYAN    = 0x0106
	CSOUNDMSG_FG_WHITE   = 0x0107

	CSOUNDMSG_FG_BOLD      = 0x0008
	CSOUNDMSG_FG_UNDERLINE = 0x0080

	CSOUNDMSG_BG_BLACK   = 0x0200
	CSOUNDMSG_BG_RED     = 0x0210
	CSOUNDMSG_BG_GREEN   = 0x0220
	CSOUNDMSG_BG_ORANGE  = 0x0230
	CSOUNDMSG_BG_BLUE    = 0x0240
	CSOUNDMSG_BG_MAGENTA = 0x0250
	CSOUNDMSG_BG_CYAN    = 0x0260
	CSOUNDMSG_BG_GREY    = 0x0270

	//-------------------------------------------------------------------------
	CSOUNDMSG_TYPE_MASK     = 0x7000
	CSOUNDMSG_FG_COLOR_MASK = 0x0107
	CSOUNDMSG_FG_ATTR_MASK  = 0x0088
	CSOUNDMSG_BG_COLOR_MASK = 0x0270
)

Variables

This section is empty.

Functions

func FileClose

func FileClose(f *C.FILE)

func FileOpen

func FileOpen(name, mode string) *C.FILE

func FreeCPvsData

func FreeCPvsData(p *PVSDATEXT)

func Initialize

func Initialize(flags int) int

Initialize Csound library with specific flags. This function is called internally by csoundCreate(), so there is generally no need to use it explicitly unless you need to avoid default initialization that sets signal handlers and atexit() callbacks. Return value is zero on success, positive if initialisation was done already, and negative on error.

Types

type AudioDeviceListHandler

type AudioDeviceListHandler func(csound CSOUND, list *CsoundAudioDevice, isOutput bool) int

type CSOUND

type CSOUND struct {
	Cs (*C.CSOUND)
}

Encapsulates an opaque pointer to a Csound instance

func Create

func Create(hostData unsafe.Pointer) CSOUND

Create an instance of Csound. Return an object with methods wrapping calls to the Csound API functions. The hostData parameter can be nil, or it can be a pointer to any sort of data; this pointer can be accessed from the Csound instance that is passed to callback routines.

func (CSOUND) A4

func (csound CSOUND) A4() MYFLT

Return the A4 frequency reference.

func (CSOUND) APIVersion

func (csound CSOUND) APIVersion() string

Return the API version number

func (CSOUND) AddSpinSample

func (csound CSOUND) AddSpinSample(frame, channel int, sample MYFLT)

Add the indicated sample into the audio input working buffer (spin); this only ever makes sense before calling PerformKsmps(). The frame and channel must be in bounds relative to ksmps and nchnls. NB: the spin buffer needs to be cleared at every k-cycle by calling ClearSpin().

func (CSOUND) AudioChannel

func (csound CSOUND) AudioChannel(name string, samples []MYFLT)

Copy the audio channel identified by name into array samples which should contain enough memory for ksmps MYFLTs.

func (CSOUND) AudioDevList

func (csound CSOUND) AudioDevList(isOutput bool) []CsoundAudioDevice

This function can be called to obtain a list of available input or output audio devices (isOutput=true for out devices, false for in devices).

list := csound.AudioDevList(true)
for i := range list {
    fmt.Printf("%d: %s (%s), %d chan\n",
          i, list[i].DeviceId, list[i].DeviceName, list[i].MaxNchnls)
}

func (CSOUND) CPUTime

func (csound CSOUND) CPUTime(rtc *C.RTCLOCK) float64

Return the elapsed CPU time (in seconds) since the specified timer structure was initialised.

func (CSOUND) ChannelDatasize

func (csound CSOUND) ChannelDatasize(name string) int

Return the size of data stored in a channel; for string channels this might change if the channel space gets reallocated.

func (CSOUND) ChannelLock

func (csound CSOUND) ChannelLock(name string) *C.int

Recover a pointer to a lock for the specified channel called 'name'. The returned lock can be locked/unlocked with the SpinLock() and SpinUnLock() functions. Return the address of the lock or nil if the channel does not exist

func (CSOUND) ChannelPtr

func (csound CSOUND) ChannelPtr(name string, chnType int) ([]MYFLT, error)

Return a pointer to the specified channel of the bus as a []MYFLT, creating the channel first if it does not exist yet. 'type' must be the bitwise OR of exactly one of the following values,

CSOUND_CONTROL_CHANNEL
  control data (one MYFLT value)
CSOUND_AUDIO_CHANNEL
  audio data (GetKsmps() MYFLT values)
CSOUND_STRING_CHANNEL
  string data (MYFLT values with enough space to store
  ChannelDatasize() characters, including the
  NULL character at the end of the string)

and at least one of these:

CSOUND_INPUT_CHANNEL
CSOUND_OUTPUT_CHANNEL

If the channel already exists, it must match the data type (control, audio, or string), however, the input/output bits are OR'd with the new value. Note that audio and string channels can only be created after calling Compile(), because the storage size is not known until then.

The returned error is nil on success, or an error message,

"Not enough memory for allocating the channel" (CSOUND_MEMORY)
"The specified name or type is invalid" (CSOUND_ERROR)

or, if a channel with the same name but incompatible type already exists, the type of the existing channel. In the case of any non-nil error value, the channel pointer is set to nil.

Note: to find out the type of a channel without actually creating or changing it, set 'chnType' to zero, so that the error value will be either the type of the channel, or CSOUND_ERROR if it does not exist.

Operations on the channel pointer are not thread-safe by default. The host is required to take care of threadsafety by

  1. with control channels use __sync_fetch_and_add() or __sync_fetch_and_or() gcc atomic builtins to get or set a channel, if available.
  2. For string and audio channels (and controls if option 1 is not available), retrieve the channel lock with ChannelLock() and use SpinLock() and SpinUnLock() to protect access to the channel.

See Top/threadsafe.c in the Csound library sources for examples. Optionally, use the channel get/set functions which are threadsafe by default.

func (CSOUND) Cleanup

func (csound CSOUND) Cleanup() int

Prints information about the end of a performance, and closes audio and MIDI devices.

Note: after calling Cleanup(), the operation of the perform functions is undefined.

func (CSOUND) ClearSpin

func (csound CSOUND) ClearSpin()

Clear the input buffer (spin).

func (CSOUND) CloseLibrary

func (csound CSOUND) CloseLibrary(library unsafe.Pointer) int

Platform-independent function to unload a shared library.

func (CSOUND) Compile

func (csound CSOUND) Compile(args []string) int

Compile Csound input files (such as an orchestra and score, or a CSD) as directed by the supplied command-line arguments, but does not perform them. Return a non-zero error code on failure. This function cannot be called during performance, and before a repeated call, Reset() needs to be called. In this (host-driven) mode, the sequence of calls should be as follows:

csound.Compile(args)
for csound.PerformBuffer() == 0 {
}
csound.Cleanup()
csound.Reset()

Calls Start() internally.

func (CSOUND) CompileArgs

func (csound CSOUND) CompileArgs(args []string) int

Read arguments, parse and compile an orchestra, read, process and load a score.

func (CSOUND) CompileCsd

func (csound CSOUND) CompileCsd(fileName string) int

Compile a Csound input file (.csd file) which includes command-line arguments, but does not perform the file. Return a non-zero error code on failure. In this (host-driven) mode, the sequence of calls should be as follows:

csound.CompileCsd(fileName)
for csound.PerformBuffer() == 0 {
}
csound.Cleanup()
csound.Reset()

NB: this function can be called during performance to replace or add new instruments and events. On a first call and if called before csound.Start(), this function behaves similarly to csound.Compile()

func (CSOUND) CompileCsdText

func (csound CSOUND) CompileCsdText(csdText string) int

Compile a Csound input file contained in a string of text, which includes command-line arguments, orchestra, score, etc., but does not perform the file. Returns a non-zero error code on failure. In this (host-driven) mode, the sequence of calls should be as follows:

csound.CompileCsdText(csound, csdText)
for csound.PerformBuffer() == 0 {
}
csound.Cleanup()
csound.Reset()

NB: A temporary file is created, the csd_text is written to the temporary file, and csound.CompileCsd is called with the name of the temporary file, which is deleted after compilation. Behavior may vary by platform.

func (CSOUND) CompileOrc

func (csound CSOUND) CompileOrc(orc string) int

Parse, and compile the given orchestra from an ASCII string, also evaluating any global space code (i-time only) this can be called during performance to compile a new orchestra.

orc := "instr 1 \n a1 rand 0dbfs/4 \n out a1 \n"
csound.CompileOrc(orc)

func (CSOUND) CompileOrcAsync

func (csound CSOUND) CompileOrcAsync(orc string) int

Async version of CompileOrc(). The code is parsed and compiled, then placed on a queue for asynchronous merge into the running engine, and evaluation. The function returns following parsing and compilation.

func (CSOUND) CompileTree

func (csound CSOUND) CompileTree(root TREE) int

Compile the given TREE node into structs for Csound to use. This can be called during performance to compile a new TREE

func (CSOUND) CompileTreeAsync

func (csound CSOUND) CompileTreeAsync(root TREE) int

Asynchronous version of CompileTree().

func (CSOUND) ControlChannel

func (csound CSOUND) ControlChannel(name string) (MYFLT, int)

Retrieve the value of control channel identified by name. The error (or success) code finding or accessing the channel is returned as well.

func (CSOUND) ControlChannelHints

func (csound CSOUND) ControlChannelHints(name string) (ControlChannelHints, int)

Return special parameters (assuming there are any) of a control channel, previously set with SetControlChannelHints() or the chnparams opcode. If the channel exists, is a control channel, the channel hints are stored in the ControlChannelHints structure.

The return value is zero if the channel exists and is a control channel, otherwise, an error code is returned.

func (CSOUND) CreateBarrier

func (csound CSOUND) CreateBarrier(max uint) unsafe.Pointer

Create a Thread Barrier. Max value parameter should be equal to number of child threads using the barrier plus one for the master thread.

func (CSOUND) CreateCircularBuffer

func (csound CSOUND) CreateCircularBuffer(numelem int) unsafe.Pointer

Create circular buffer with numelem number of MYFLT elements. It should be used like:

rb := csound.CreateCircularBuffer(1024)

func (CSOUND) CreateGlobalVariable

func (csound CSOUND) CreateGlobalVariable(name string, nbytes uint) int

Allocate nbytes bytes of memory that can be accessed later by calling QueryGlobalVariable() with the specified name; the space is cleared to zero.

Return CSOUND_SUCCESS on success, CSOUND_ERROR in case of invalid parameters (zero nbytes, invalid or already used name), or CSOUND_MEMORY if there is not enough memory.

func (CSOUND) CreateMessageBuffer

func (csound CSOUND) CreateMessageBuffer(toStdOut bool)

Create a buffer for storing messages printed by Csound.

Should be called after creating a Csound instance and the buffer can be freed by calling DestroyMessageBuffer() before deleting the Csound instance. You will generally want to call Cleanup() to make sure the last messages are flushed to the message buffer before destroying Csound.

If 'toStdOut' is true, the messages are also printed to stdout and stderr (depending on the type of the message), in addition to being stored in the buffer.

Using the message buffer ties up the internal message callback, so SetMessageCallback should not be called after creating the message buffer.

func (CSOUND) CreateMutex

func (csound CSOUND) CreateMutex(isRecursive bool) unsafe.Pointer

Create and return a mutex object, or nil if not successful.

Mutexes can be faster than the more general purpose monitor objects returned by CreateThreadLock() on some platforms, and can also be recursive, but the result of unlocking a mutex that is owned by another thread or is not locked is undefined.

If 'isRecursive' is true, the mutex can be re-locked multiple times by the same thread, requiring an equal number of unlock calls; otherwise, attempting to re-lock the mutex results in undefined behavior.

Note: the handles returned by CreateThreadLock() and CreateMutex() are not compatible.

func (CSOUND) CreateThreadLock

func (csound CSOUND) CreateThreadLock() unsafe.Pointer

Create and return a monitor object, or nil if not successful. The object is initially in signaled (notified) state.

func (CSOUND) CurrentThreadId

func (csound CSOUND) CurrentThreadId() unsafe.Pointer

Return the ID of the currently executing thread, or nil for failure.

NOTE: The return value can be used as a pointer to a thread object, but it should not be compared as a pointer. The pointed to values should be compared, and the user must free the pointer after use.

func (CSOUND) CurrentTimeSamples

func (csound CSOUND) CurrentTimeSamples() int

Return the current performance time in samples.

func (CSOUND) Debug

func (csound CSOUND) Debug() bool

Return whether Csound is set to print debug messages sent through the DebugMsg() internal API function.

func (CSOUND) DeleteTree

func (csound CSOUND) DeleteTree(tree TREE)

Free the resources associated with the TREE tree. This function should be called whenever the TREE was created with ParseOrc and memory can be deallocated.

func (*CSOUND) Destroy

func (csound *CSOUND) Destroy()

Destroy an instance of Csound.

func (CSOUND) DestroyBarrier

func (csound CSOUND) DestroyBarrier(barrier unsafe.Pointer) int

Destroy a Thread Barrier.

func (CSOUND) DestroyCircularBuffer

func (csound CSOUND) DestroyCircularBuffer(circularBuffer unsafe.Pointer)

Free circular buffer.

func (CSOUND) DestroyGlobalVariable

func (csound CSOUND) DestroyGlobalVariable(name string) int

Free memory allocated for "name" and remove "name" from the database. Return value is CSOUND_SUCCESS on success, or CSOUND_ERROR if the name is not defined.

func (CSOUND) DestroyMessageBuffer

func (csound CSOUND) DestroyMessageBuffer()

Release all memory used by the message buffer.

func (CSOUND) DestroyMutex

func (csound CSOUND) DestroyMutex(mutex unsafe.Pointer)

Destroy the indicated mutex object. Destroying a mutex that is currently owned by a thread results in undefined behavior.

func (CSOUND) DestroyThreadLock

func (csound CSOUND) DestroyThreadLock(lock unsafe.Pointer)

Destroy the indicated monitor object.

func (CSOUND) Env

func (csound CSOUND) Env(name string) string

Get the value of environment variable 'name', searching in this order: local environment of 'csound', variables set with SetGlobalEnv(), and system environment variables. Should be called after PreCompile() or Compile(). Return value is nil if the variable is not set.

func (CSOUND) EvalCode

func (csound CSOUND) EvalCode(code string) MYFLT

Parse and compile an orchestra given on a string, evaluating any global space code (i-time only). On SUCCESS it returns a value passed to the 'return' opcode in global space.

code := "i1 = 2 + 2 \n return i1 \n"
retval := csound.EvalCode(code)

func (CSOUND) FirstMessage

func (csound CSOUND) FirstMessage() string

Return the first message from the buffer.

func (CSOUND) FirstMessageAttr

func (csound CSOUND) FirstMessageAttr() int

Return the attribute parameter (see msg_attr.h) of the first message in the buffer.

func (CSOUND) FlushCircularBuffer

func (csound CSOUND) FlushCircularBuffer(circularBuffer unsafe.Pointer)

Empty circular buffer of any remaining data. This function shuould only be used if there is no reader actively getting data from the buffer.

circular_buffer - pointer to an existing circular buffer

func (CSOUND) FreeRandMTState

func (csound CSOUND) FreeRandMTState(p *C.CsoundRandMTState)

Free the memory pointed to by the C.CsoundRandMTState pointer.

func (CSOUND) Get0dBFS

func (csound CSOUND) Get0dBFS() MYFLT

Return the 0dBFS level of the spin/spout buffers.

func (CSOUND) HostData

func (csound CSOUND) HostData() unsafe.Pointer

Return host data.

func (CSOUND) InitTimerStruct

func (csound CSOUND) InitTimerStruct() C.RTCLOCK

Initialise a timer structure.

func (CSOUND) InitializeCscore

func (csound CSOUND) InitializeCscore(insco, outsco *C.FILE) int

Prepare an instance of Csound for Cscore processing outside of running an orchestra (i.e. "standalone Cscore"). It is an alternative to PreCompile(), Compile(), and Perform*() and should not be used with these functions.

You must call this function before using the interface in "cscore.h" when you do not wish to compile an orchestra. Pass it the already open *C.FILE pointers to the input and output score files.

It returns CSOUND_SUCCESS on success and CSOUND_INITIALIZATION or other error code if it fails.

func (CSOUND) InputBuffer

func (csound CSOUND) InputBuffer() []MYFLT

Return the Csound audio input buffer as a []MYFLT. Enable external software to write audio into Csound before calling PerformBuffer.

func (CSOUND) InputBufferSize

func (csound CSOUND) InputBufferSize() int

Return the number of samples in Csound input buffer.

func (CSOUND) InputMessage

func (csound CSOUND) InputMessage(message string)

Input a string (as if from a console), used for line events.

func (CSOUND) InputMessageAsync

func (csound CSOUND) InputMessageAsync(message string)

Asynchronous version of InputMessage().

func (CSOUND) IsNamedGEN

func (csound CSOUND) IsNamedGEN(num int) int

Check if a given GEN number num is a named GEN. If so, it returns the string length. Otherwise it returns 0.

func (CSOUND) IsScorePending

func (csound CSOUND) IsScorePending() bool

Tell whether Csound score events are performed or not, independently of real-time MIDI events (see SetScorePending()).

func (CSOUND) JoinThread

func (csound CSOUND) JoinThread(thread unsafe.Pointer) uintptr

Wait until the indicated thread's routine has finished. Return the value returned by the thread routine.

func (CSOUND) KeyPress

func (csound CSOUND) KeyPress(c byte)

Set the ASCII code of the most recent key pressed. This value is used by the 'sensekey' opcode if a callback for returning keyboard events is not set (see RegisterKeyboardCallback()).

func (CSOUND) KillInstance

func (csound CSOUND) KillInstance(instr MYFLT, instrName string, mode int,
	allowRelease bool) int

Kill off one or more running instances of an instrument identified by instr (number) or instrName (name). If instrName is nil, the instrument number is used. Mode is a sum of the following values:

0, 1, 2: kill all instances (0), oldest only (1), or newest (2)
4: only turnoff notes with exactly matching (fractional) instr number
8: only turnoff notes with indefinite duration (p3 < 0 or MIDI)

allowRelease: if true, the killed instances are allowed to release.

func (CSOUND) Kr

func (csound CSOUND) Kr() MYFLT

Return the number of control samples per second.

func (CSOUND) Ksmps

func (csound CSOUND) Ksmps() int

Return the number of audio sample frames per control sample.

func (CSOUND) LibrarySymbol

func (csound CSOUND) LibrarySymbol(library unsafe.Pointer,
	symbolName string) unsafe.Pointer

Platform-independent function to get a symbol address in a shared library.

func (CSOUND) ListChannels

func (csound CSOUND) ListChannels() ([]ControlChannelInfo, error)

Return a list of allocated channels. A ControlChannelInfo structure contains the channel characteristics. The error value is nil, or a CSOUND_MEMORY message, if there is not enough memory for allocating the list. In the case of no channels or an error, the list is set to nil.

Notes: The list will become inconsistant after calling Reset().

func (CSOUND) ListUtilities

func (csound CSOUND) ListUtilities() ([]string, error)

Return a list of registered utility names. The return value may be nil in case of an error.

func (CSOUND) LockMutex

func (csound CSOUND) LockMutex(mutex unsafe.Pointer)

Acquire the indicated mutex object; if it is already in use by another thread, the function waits until the mutex is released by the other thread.

func (CSOUND) LockMutexNoWait

func (csound CSOUND) LockMutexNoWait(mutex unsafe.Pointer) int

Acquire the indicated mutex object and return zero, unless it is already in use by another thread, in which case a non-zero value is returned immediately, rather than waiting until the mutex becomes available.

Note: this function may be unimplemented on Windows.

func (CSOUND) Message

func (csound CSOUND) Message(format string, v ...interface{})

Displays an informal message.

func (CSOUND) MessageCnt

func (csound CSOUND) MessageCnt() int

Return the number of pending messages in the buffer.

func (CSOUND) MessageLevel

func (csound CSOUND) MessageLevel() int

Return the Csound message level (from 0 to 231).

func (CSOUND) MessageS

func (csound CSOUND) MessageS(attr int, format string, v ...interface{})

Print message with special attributes (see const above for the list of available attributes). With attr=0, csoundMessageS() is identical to csoundMessage().

func (CSOUND) MidiDevList

func (csound CSOUND) MidiDevList(isOutput bool) []CsoundMidiDevice

This function can be called to obtain a list of available input or output midi devices. (see also AudioDevList())

func (CSOUND) Module

func (csound CSOUND) Module(number int) (name, mtype string, error int)

Retrieve a module name and type ("audio" or "midi") given a number. Modules are added to list as csound loads them. Return CSOUND_SUCCESS on success and CSOUND_ERROR if module number was not found

var name, mtype string
err := CSOUND_SUCCESS
n := 0;
for err != CSOUND_ERROR {
    name, mtype, err = csound.Module(n++)
    fmt.Printf("Module %d:  %s (%s)\n", n, name, mtype)
}

func (CSOUND) NamedGEN

func (csound CSOUND) NamedGEN(num, namelen int) string

Get the GEN name from a number num, if this is a named GEN. The final parameter is the max len of the string.

func (CSOUND) NamedGens

func (csound CSOUND) NamedGens() []NamedGen

Find the list of named gens.

func (CSOUND) Nchnls

func (csound CSOUND) Nchnls() int

Return the number of audio output channels. Set through the nchnls header variable in the csd file.

func (CSOUND) NchnlsInput

func (csound CSOUND) NchnlsInput() int

Return the number of audio input channels. Set through the nchnls_i header variable in the csd file. If this variable is not set, the value is taken from nchnls.

func (CSOUND) NoMessage

func (csound CSOUND) NoMessage()

This is not an API function. It passes to csoundSetMessageCallback a callback function that does nothing, so that Csound will not print any message.

func (CSOUND) NotifyThreadLock

func (csound CSOUND) NotifyThreadLock(lock unsafe.Pointer)

Notify the indicated monitor object.

func (CSOUND) OpcodeList

func (csound CSOUND) OpcodeList() []OpcodeListEntry

Get an alphabetically sorted list of all opcodes. Should be called after externals are loaded by Compile(). Return the number of opcodes, or a negative error code on failure.

func (CSOUND) OpenLibrary

func (csound CSOUND) OpenLibrary(libraryPath string) (int, unsafe.Pointer)

Platform-independent function to load a shared library.

func (CSOUND) OutputBuffer

func (csound CSOUND) OutputBuffer() []MYFLT

Return the Csound audio output buffer as a []MYFLT. Enable external software to read audio from Csound after calling PerformBuffer.

func (CSOUND) OutputBufferSize

func (csound CSOUND) OutputBufferSize() int

Return the number of samples in Csound output buffer.

func (CSOUND) OutputFormat

func (csound CSOUND) OutputFormat() (otype, format string)

Get output type and format.

func (CSOUND) OutputName

func (csound CSOUND) OutputName() string

Return the audio output name (-o).

func (CSOUND) Params

func (csound CSOUND) Params(p *CsoundParams)

Get the current set of parameters from a CSOUND instance in a CsoundParams structure. See SetParams().

func (CSOUND) ParseOrc

func (csound CSOUND) ParseOrc(orc string) TREE

Parse the given orchestra from an ASCII string into a TREE. This can be called during performance to parse new code.

func (CSOUND) PeekCircularBuffer

func (csound CSOUND) PeekCircularBuffer(circularBuffer unsafe.Pointer, out []MYFLT,
	items int) int

Read from circular buffer without removing them from the buffer.

circular_buffer - pointer to an existing circular buffer
out - preallocated buffer with at least items number of elements, where
      buffer contents will be read into

items - number of samples to be read Return the actual number of items read (0 <= n <= items)

func (CSOUND) Perform

func (csound CSOUND) Perform() int

Senses input events and performs audio output until the end of score is reached (positive return value), an error occurs (negative return value), or performance is stopped by calling Stop() from another thread (zero return value).

Note that Compile() or CompileOrc(), ReadScore(), Start() must be called first.

In the case of zero return value, Perform() can be called again to continue the stopped performance. Otherwise, Reset() should be called to clean up after the finished or failed performance.

func (CSOUND) PerformBuffer

func (csound CSOUND) PerformBuffer() int

Performs Csound, sensing real-time and score events and processing one buffer's worth (-b frames) of interleaved audio. Return a pointer to the new output audio in 'outputAudio'

Note that Compile must be called first, then call OutputBuffer() and InputBuffer() to get the pointer to csound's I/O buffers.

Return false during performance, and true when performance is finished.

func (CSOUND) PerformKsmps

func (csound CSOUND) PerformKsmps() int

Senses input events, and performs one control sample worth (ksmps) of audio output.

Note that Compile() or CompileOrc(), ReadScore(), Start() must be called first.

Return false during performance, and true when performance is finished. If called until it returns true, will perform an entire score. Enables external software to control the execution of Csound, and to synchronize performance with audio input and output.

func (CSOUND) PopFirstMessage

func (csound CSOUND) PopFirstMessage()

Remove the first message from the buffer.

func (CSOUND) PvsChannel

func (csound CSOUND) PvsChannel(fout *PVSDATEXT, name string) int

Receive a PVSDAT fout from the pvsout opcode (f-rate) at channel 'name'. Return zero on success, CSOUND_ERROR if the index is invalid or if fsig framesizes are incompatible, CSOUND_MEMORY if there is not enough memory to extend the bus.

func (CSOUND) QueryGlobalVariable

func (csound CSOUND) QueryGlobalVariable(name string) unsafe.Pointer

Get pointer to space allocated with the name "name". Returns nil if the specified name is not defined.

func (CSOUND) QueryGlobalVariableNoCheck

func (csound CSOUND) QueryGlobalVariableNoCheck(name string) unsafe.Pointer

This function is the same as QueryGlobalVariable(), except the variable is assumed to exist and no error checking is done. Faster, but may crash or return an invalid pointer if 'name' is not defined.

func (CSOUND) Rand31

func (csound CSOUND) Rand31(seedVal *int32) int32

Simple linear congruential random number generator:

(*seedVal) = (*seedVal) * 742938285 % 2147483647

The initial value of *seedVal must be in the range 1 to 2147483646. Return the next number from the pseudo-random sequence, in the range 1 to 2147483646.

func (CSOUND) RandMT

func (csound CSOUND) RandMT(p *C.CsoundRandMTState) uint32

Return next random number from MT19937 generator. The PRNG must be initialised first by calling SeedRandMT().

func (CSOUND) RandomSeedFromTime

func (csound CSOUND) RandomSeedFromTime() uint32

Return a 32-bit unsigned integer to be used as seed from current time.

func (CSOUND) ReadCircularBuffer

func (csound CSOUND) ReadCircularBuffer(circularBuffer unsafe.Pointer, out []MYFLT,
	items int) int

Read from circular buffer

circular_buffer - pointer to an existing circular buffer
out - preallocated buffer with at least items number of elements, where
      buffer contents will be read into
items - number of samples to be read

Return the actual number of items read (0 <= n <= items)

func (CSOUND) ReadScore

func (csound CSOUND) ReadScore(str string) int

Read, preprocess, and load a score from an ASCII string. It can be called repeatedly, with the new score events being added to the currently scheduled ones.

func (CSOUND) ReadScoreAsync

func (csound CSOUND) ReadScoreAsync(str string)

Asynchronous version of ReadScore().

func (CSOUND) RealTime

func (csound CSOUND) RealTime(rtc *C.RTCLOCK) float64

Return the elapsed real time (in seconds) since the specified timer structure was initialised.

func (CSOUND) RegisterSenseEventCallback

func (csound CSOUND) RegisterSenseEventCallback(f SenseEventHandler,
	userData unsafe.Pointer) (ret int, err error)

Register a function to be called once in every control period by sensevents(). Any number of functions may be registered, and will be called in the order of registration. The callback function takes two arguments: the Csound instance pointer, and the userData pointer as passed to this function. This facility can be used to ensure a function is called synchronously before every csound control buffer processing. It is important to make sure no blocking operations are performed in the callback. The callbacks are cleared on Cleanup(). Returns zero on success.

func (CSOUND) Reset

func (csound CSOUND) Reset()

Resets all internal memory and state in preparation for a new performance. Enables external software to run successive Csound performances without reloading Csound. Implies Cleanup(), unless already called.

func (CSOUND) RewindScore

func (csound CSOUND) RewindScore()

Rewind a compiled Csound score to the time specified with SetScoreOffsetSeconds().

func (CSOUND) RtPlaydUserData

func (csound CSOUND) RtPlaydUserData() unsafe.Pointer

Return a pointer to user data for real time audio output.

func (CSOUND) RtRecordUserData

func (csound CSOUND) RtRecordUserData() unsafe.Pointer

Return a pointer to user data for real time audio input.

func (CSOUND) RunCommand

func (csound CSOUND) RunCommand(args []string, noWait bool) int

Run an external command with the arguments specified in 'args'. args[0] is the name of the program to execute (if not a full path file name, it is searched in the directories defined by the PATH environment variable).

If 'noWait' is false, the function waits until the external program finishes, otherwise it returns immediately. In the first case, a non-negative return value is the exit status of the command (0 to 255), otherwise it is the PID of the newly created process. On error, a negative value is returned.

func (CSOUND) RunUtility

func (csound CSOUND) RunUtility(name string, args []string) int

Run utility with the specified name and command line arguments. Should be called after loading utility plugins with PreCompile(); use Reset() to clean up after calling this function. Returns zero if the utility was run successfully.

func (CSOUND) ScoreEvent

func (csound CSOUND) ScoreEvent(eventType byte, pFields []MYFLT) int

Send a new score event. 'eventType' is the score event type ('a', 'i', 'q', 'f', or 'e'). 'pFields' is slice of MYFLT with all the pfields for this event, starting with the p1 value specified in pFields[0].

func (CSOUND) ScoreEventAbsolute

func (csound CSOUND) ScoreEventAbsolute(eventType byte, pFields []MYFLT,
	timeOfs float64) int

Like ScoreEvent(), this function inserts a score event, but at absolute time with respect to the start of performance, or from an offset set with timeOfs.

func (CSOUND) ScoreEventAbsoluteAsync

func (csound CSOUND) ScoreEventAbsoluteAsync(eventType byte, pFields []MYFLT,
	timeOfs float64)

Asynchronous version of ScoreEventAbsolute().

func (CSOUND) ScoreEventAsync

func (csound CSOUND) ScoreEventAsync(eventType byte, pFields []MYFLT)

Asynchronous version of ScoreEvent().

func (CSOUND) ScoreExtract

func (csound CSOUND) ScoreExtract(inFile, outFile, extractFile *C.FILE) int

Extract from 'inFile', controlled by 'extractFile', and write the result to 'outFile'. The Csound instance should be initialised with PreCompile() before calling this function, and Reset() should be called after score extraction to clean up. The return value is zero on success.

func (CSOUND) ScoreOffsetSeconds

func (csound CSOUND) ScoreOffsetSeconds() MYFLT

Return the score time beginning at which score events will actually immediately be performed (see SetScoreOffsetSeconds()).

func (CSOUND) ScoreSort

func (csound CSOUND) ScoreSort(inFile, outFile *C.FILE) int

Sort score file 'inFile' and write the result to 'outFile'. The Csound instance should be initialised with PreCompile() before calling this function, and Reset() should be called after sorting the score to clean up. On success, zero is returned.

func (CSOUND) ScoreTime

func (csound CSOUND) ScoreTime() float64

Return the current score time in seconds since the beginning of performance.

func (CSOUND) SeedRandMT

func (csound CSOUND) SeedRandMT(initKey []uint32) *C.CsoundRandMTState

Initialise Mersenne Twister (MT19937) random number generator, using len(initKey) unsigned 32 bit values from 'initKey' as seed. One has to free the memory used to store the PNRG state, when the PNRG is not needed anymore (see FreeRandMTState())

func (CSOUND) SetAudioChannel

func (csound CSOUND) SetAudioChannel(name string, samples []MYFLT)

Set the audio channel identified by name with data from array samples which should contain at least ksmps MYFLTs.

func (CSOUND) SetAudioDeviceListCallback

func (csound CSOUND) SetAudioDeviceListCallback(f AudioDeviceListHandler)

Set a function that is called to obtain a list of audio devices. This should be set by rtaudio modules and should not be set by hosts. (See AudioDevList())

func (CSOUND) SetControlChannel

func (csound CSOUND) SetControlChannel(name string, val MYFLT)

Set the value of control channel identified by name.

func (CSOUND) SetControlChannelHints

func (csound CSOUND) SetControlChannelHints(name string, hints ControlChannelHints) int

Set parameters hints for a control channel. These hints have no internal function but can be used by front ends to construct GUIs or to constrain values. See the ControlChannelHints structure for details. Returns zero on success, or a non-zero error code on failure:

CSOUND_ERROR:  the channel does not exist, is not a control channel,
               or the specified parameters are invalid
CSOUND_MEMORY: could not allocate memory

func (CSOUND) SetCscoreCallback

func (csound CSOUND) SetCscoreCallback(f CscoreHandler)

Set an external callback for Cscore processing. Pass nil to reset to the internal cscore() function (which does nothing). This callback is retained after a Reset() call.

func (CSOUND) SetDebug

func (csound CSOUND) SetDebug(debug bool)

Set whether Csound prints debug messages from the DebugMsg() internal API function.

func (CSOUND) SetDrawGraphCallback

func (csound CSOUND) SetDrawGraphCallback(f GraphHandler)

Called by external software to set Csound's DrawGraph function.

func (CSOUND) SetExitGraphCallback

func (csound CSOUND) SetExitGraphCallback(f ExitGraphHandler)

Called by external software to set Csound's ExitGraph function.

func (CSOUND) SetExternalMidiErrorStringCallback

func (csound CSOUND) SetExternalMidiErrorStringCallback(f ExternalMidiErrorStringHandler)

Set callback for converting MIDI error codes to strings.

func (CSOUND) SetExternalMidiInCloseCallback

func (csound CSOUND) SetExternalMidiInCloseCallback(f ExternalMidiInCloseHandler)

Set callback for closing real time MIDI input.

func (CSOUND) SetExternalMidiInOpenCallback

func (csound CSOUND) SetExternalMidiInOpenCallback(f ExternalMidiInOpenHandler)

Set callback for opening real time MIDI input.

func (CSOUND) SetExternalMidiOutCloseCallback

func (csound CSOUND) SetExternalMidiOutCloseCallback(f ExternalMidiOutCloseHandler)

Set callback for closing real time MIDI output.

func (CSOUND) SetExternalMidiOutOpenCallback

func (csound CSOUND) SetExternalMidiOutOpenCallback(f ExternalMidiOutOpenHandler)

Set callback for opening real time MIDI output.

func (CSOUND) SetExternalMidiReadCallback

func (csound CSOUND) SetExternalMidiReadCallback(f ExternalMidiReadHandler)

Set callback for reading from real time MIDI input.

func (CSOUND) SetExternalMidiWriteCallback

func (csound CSOUND) SetExternalMidiWriteCallback(f ExternalMidiWriteHandler)

Set callback for writing to real time MIDI output.

func (CSOUND) SetFileOpenCallback

func (csound CSOUND) SetFileOpenCallback(f FileOpenHandler)

Set an external callback for receiving notices whenever Csound opens a file. The callback is made after the file is successfully opened. The following information is passed to the callback:

string pathname of the file; either full or relative to current dir
int    a file type code from the enumeration CSOUND_FILETYPES
bool   true if Csound is writing the file, false if reading
bool   true if a temporary file that Csound will delete; false if not

Pass nil to disable the callback. This callback is retained after a Reset() call.

func (CSOUND) SetGlobalEnv

func (csound CSOUND) SetGlobalEnv(name, value string) int

Set the global value of environment variable 'name' to 'value', or delete variable if 'value' is nil. It is not safe to call this function while any Csound instances are active. Return zero on success.

func (CSOUND) SetHostData

func (csound CSOUND) SetHostData(hostData unsafe.Pointer)

Set host data.

func (CSOUND) SetHostImplementedAudioIO

func (csound CSOUND) SetHostImplementedAudioIO(state, bufSize int)

Calling this function with a non-zero 'state' value between Create() and the start of performance will disable all default handling of sound I/O by the Csound library, allowing the host application to use the spin/spout/input/output buffers directly. For applications using spin/spout, bufSize should be set to 0. If 'bufSize' is greater than zero, the buffer size (-b) will be set to the integer multiple of ksmps that is nearest to the value specified.

func (CSOUND) SetHostImplementedMIDIIO

func (csound CSOUND) SetHostImplementedMIDIIO(state bool)

Call this function with state true if the host is implementing MIDI via the callbacks below.

func (CSOUND) SetInput

func (csound CSOUND) SetInput(name string)

Set input source.

func (CSOUND) SetInputChannelCallback

func (csound CSOUND) SetInputChannelCallback(f ChannelHandler)

Set the function which will be called whenever the invalue opcode is used.

func (CSOUND) SetIsGraphable

func (csound CSOUND) SetIsGraphable(isGraphable int) int

Tell Csound whether external graphic table display is supported. Return the previously set value (initially zero).

func (CSOUND) SetKillGraphCallback

func (csound CSOUND) SetKillGraphCallback(f GraphHandler)

Called by external software to set Csound's KillGraph function.

func (CSOUND) SetLanguage

func (csound CSOUND) SetLanguage(langCode Cslanguage_t)

Set language to 'langCode' (langCode can be for example CSLANGUAGE_ENGLISH_UK or CSLANGUAGE_FRENCH or many others, see n_getstr.h for the list of languages). This affects all Csound instances running in the address space of the current process. The special language code CSLANGUAGE_DEFAULT can be used to disable translation of messages and free all memory allocated by a previous call to SetLanguage(). SetLanguage() loads all files for the selected language from the directory specified by the CSSTRNGS environment variable.

func (CSOUND) SetMIDIFileInput

func (csound CSOUND) SetMIDIFileInput(name string)

Set MIDI file input name.

func (CSOUND) SetMIDIFileOutput

func (csound CSOUND) SetMIDIFileOutput(name string)

Set MIDI file output name.

func (CSOUND) SetMIDIInput

func (csound CSOUND) SetMIDIInput(name string)

Set MIDI input device name/number.

func (CSOUND) SetMIDIModule

func (csound CSOUND) SetMIDIModule(module string)

Set the current MIDI IO module.

func (CSOUND) SetMIDIOutput

func (csound CSOUND) SetMIDIOutput(name string)

Set MIDI output device name/number.

func (CSOUND) SetMakeGraphCallback

func (csound CSOUND) SetMakeGraphCallback(f MakeGraphHandler)

Called by external software to set Csound's MakeGraph function.

func (CSOUND) SetMessageLevel

func (csound CSOUND) SetMessageLevel(messageLevel int)

Set the Csound message level (from 0 to 231).

func (CSOUND) SetMidiDeviceListCallback

func (csound CSOUND) SetMidiDeviceListCallback(f MidiDeviceListHandler)

Set a function that is called to obtain a list of MIDI devices. This should be set by IO plugins, and should not be set by hosts. (See MidiDevList())

func (CSOUND) SetOption

func (csound CSOUND) SetOption(option string) int

Set a single csound option (flag). Return CSOUND_SUCCESS on success. NB: blank spaces are not allowed

func (CSOUND) SetOutput

func (csound CSOUND) SetOutput(name, otype, format string)

Set output destination, type and format type can be one of "wav","aiff", "au","raw", "paf", "svx", "nist", "voc", "ircam","w64","mat4", "mat5", "pvf","xi", "htk","sds","avr","wavex","sd2", "flac", "caf","wve","ogg","mpc2k","rf64", or nil (use default or realtime IO). format can be one of "alaw", "schar", "uchar", "float", "double", "long", "short", "ulaw", "24bit", "vorbis", or nil (use default or realtime IO).

For RT audio, use DeviceId from CsoundAudioDevice for a given audio device.

func (CSOUND) SetOutputChannelCallback

func (csound CSOUND) SetOutputChannelCallback(f ChannelHandler)

Set the function which will be called whenever the outvalue opcode is used.

func (CSOUND) SetParams

func (csound CSOUND) SetParams(p *CsoundParams)

Configure Csound with a given set of parameters defined in the CsoundParams structure. These parameters are the part of the OPARMS struct that are configurable through command line flags. The CsoundParams structure can be obtained using Params(). These options should only be changed before performance has started.

func (CSOUND) SetPlayOpenCallback

func (csound CSOUND) SetPlayOpenCallback(f PlayOpenHandler)

Set a function to be called by Csound for opening real-time audio playback.

func (CSOUND) SetPvsChannel

func (csound CSOUND) SetPvsChannel(fin *PVSDATEXT, name string) int

Send a PVSDATEX fin to the pvsin opcode (f-rate) for channel 'name'. Return zero on success, CSOUND_ERROR if the index is invalid or fsig framesizes are incompatible, CSOUND_MEMORY if there is not enough memory to extend the bus.

func (CSOUND) SetRTAudioModule

func (csound CSOUND) SetRTAudioModule(module string)

Set the current RT audio module.

func (CSOUND) SetRecOpenCallback

func (csound CSOUND) SetRecOpenCallback(f RecOpenHandler)

Set a function to be called by Csound for opening real-time audio recording.

func (CSOUND) SetRtCloseCallback

func (csound CSOUND) SetRtCloseCallback(f RtCloseHandler)

Set a function to be called by Csound for closing real-time audio playback and recording.

func (CSOUND) SetRtPlayCallback

func (csound CSOUND) SetRtPlayCallback(f RtPlayHandler)

Set a function to be called by Csound for performing real-time audio playback.

func (CSOUND) SetRtRecordCallback

func (csound CSOUND) SetRtRecordCallback(f RtRecordHandler)

Set a function to be called by Csound for performing real-time audio recording.

func (CSOUND) SetScoreOffsetSeconds

func (csound CSOUND) SetScoreOffsetSeconds(time MYFLT)

Csound score events prior to the specified time are not performed, and performance begins immediately at the specified time (real-time events will continue to be performed as they are received). Can be used by external software, such as a VST host, to begin score performance midway through a Csound score, for example to repeat a loop in a sequencer, or to synchronize other events with the Csound score.

func (CSOUND) SetScorePending

func (csound CSOUND) SetScorePending(pending bool)

Set whether Csound score events are performed or not (real-time events will continue to be performed). Can be used by external software, such as a VST host, to turn off performance of score events (while continuing to perform real-time events), for example to mute a Csound score while working on other tracks of a piece, or to play the Csound instruments live.

func (CSOUND) SetSpinSample

func (csound CSOUND) SetSpinSample(frame, channel int, sample MYFLT)

Set the audio input working buffer (spin) to the indicated sample this only ever makes sense before calling PerformKsmps(). The frame and channel must be in bounds relative to ksmps and nchnls.

func (CSOUND) SetStringChannel

func (csound CSOUND) SetStringChannel(name, str string)

Set the string channel identified by name with str.

func (CSOUND) SetYieldCallback

func (csound CSOUND) SetYieldCallback(f YieldHandler)

Called by external software to set a function for checking system events, yielding cpu time for coopertative multitasking, etc. This function is optional. It is often used as a way to 'turn off' Csound, allowing it to exit gracefully. In addition, some operations like utility analysis routines are not reentrant and you should use this function to do any kind of updating during the operation. Returns an 'OK to continue' boolean.

func (CSOUND) SizeOfMYFLT

func (csound CSOUND) SizeOfMYFLT() int

Return the size of MYFLT in bytes.

func (CSOUND) Sleep

func (csound CSOUND) Sleep(ms uint)

Wait for at least the specified number of milliseconds, yielding the CPU to other threads.

func (CSOUND) Spin

func (csound CSOUND) Spin() []MYFLT

Return the Csound audio input working buffer (spin) as a []MYFLT. Enable external software to write audio into Csound before calling PerformKsmps.

func (CSOUND) SpinLock

func (csound CSOUND) SpinLock(spinlock *int32)

Locks the spinlock.

func (CSOUND) SpinLockInit

func (csound CSOUND) SpinLockInit(spinlock *int32) int

Inits the spinlock. If the spinlock is not locked, lock it and return; if is is locked, wait until it is unlocked, then lock it and return. Uses atomic compare and swap operations that are safe across processors and safe for out of order operations, and which are more efficient than operating system locks. Use spinlocks to protect access to shared data, especially in functions that do little more than read or write such data, for example:

var lock int32
cs.SpinLockInit(&lock)
func write(cs CSOUND, frames, signal) {
    cs.spinLock(&lock)
    for frame := range frames {
        global_buffer[frame] = global_buffer[frame] + signal[frame]
    }
    cs.spinUnlock(&lock)

func (CSOUND) SpinTryLock

func (csound CSOUND) SpinTryLock(spinlock *int32) int

Tries the spinlock.

func (CSOUND) SpinUnLock

func (csound CSOUND) SpinUnLock(spinlock *int32)

Unlock the specified spinlock; (see SpinLock()).

func (CSOUND) Spout

func (csound CSOUND) Spout() []MYFLT

Return the Csound audio output working buffer (spout) as a []MYFLT. Enable external software to read audio from Csound after calling PerformKsmps.

func (CSOUND) SpoutSample

func (csound CSOUND) SpoutSample(frame, channel int) MYFLT

Return the indicated sample from the Csound audio output working buffer (spout); only ever makes sense after calling PerformKsmps(). The frame and channel must be in bounds relative to ksmps and nchnls.

func (CSOUND) Sr

func (csound CSOUND) Sr() MYFLT

Return the number of audio sample frames per second.

func (CSOUND) Start

func (csound CSOUND) Start() int

Prepares Csound for performance. Normally called after compiling a csd file or an orc file, in which case score preprocessing is performed and performance terminates when the score terminates. However, if called before compiling a csd file or an orc file, score preprocessing is not performed and "i" statements are dispatched as real-time events, the <CsOptions> tag is ignored, and performance continues indefinitely or until ended using the API. NB: this is called internally by Compile(), therefore it is only required if performance is started without a call to that function.

func (CSOUND) Stop

func (csound CSOUND) Stop()

Stops a Perform() running in another thread. Note that it is not guaranteed that Perform() has already stopped when this function returns.

func (CSOUND) StringChannel

func (csound CSOUND) StringChannel(name string) string

Return a copy of the string channel identified by name.

func (CSOUND) Table

func (csound CSOUND) Table(tableNum int) ([]MYFLT, error)

Return a pointer to function table 'tableNum' as a []MYFLT. If the table does not exist, the pointer is set to nil and an error is returned.

func (CSOUND) TableArgs

func (csound CSOUND) TableArgs(tableNum int) ([]MYFLT, error)

Return a pointer to the arguments used to generate function table 'tableNum' as a []MYFLT. If the table does not exist, the pointer is set to nil and an error is returned. NB: the argument list starts with the GEN number and is followed by its parameters. eg. f 1 0 1024 10 1 0.5 yields the list [10.0, 1.0, 0.5]

func (CSOUND) TableCopyIn

func (csound CSOUND) TableCopyIn(table int, src []MYFLT)

Copy the contents of an array src into a given function table. The table number is assumed to be valid, and the table needs to have sufficient space to receive all the array contents.

func (CSOUND) TableCopyInAsync

func (csound CSOUND) TableCopyInAsync(table int, src []MYFLT)

Asynchronous version of TableCopyIn().

func (CSOUND) TableCopyOut

func (csound CSOUND) TableCopyOut(table int, dest []MYFLT)

Copy the contents of a function table into a supplied array dest. The table number is assumed to be valid, and the destination needs to have sufficient space to receive all the function table contents.

func (CSOUND) TableCopyOutAsync

func (csound CSOUND) TableCopyOutAsync(table int, dest []MYFLT)

Asynchronous version of TableCopyOut().

func (CSOUND) TableGet

func (csound CSOUND) TableGet(table, index int) MYFLT

Return the value of a slot in a function table. The table number and index are assumed to be valid.

func (CSOUND) TableLength

func (csound CSOUND) TableLength(table int) int

Return the length of a function table (not including the guard point), or -1 if the table does not exist.

func (CSOUND) TableSet

func (csound CSOUND) TableSet(table, index int, value MYFLT)

Set the value of a slot in a function table. The table number and index are assumed to be valid.

func (CSOUND) UnlockMutex

func (csound CSOUND) UnlockMutex(mutex unsafe.Pointer)

Release the indicated mutex object, which should be owned by the current thread, otherwise the operation of this function is undefined. A recursive mutex needs to be unlocked as many times as it was locked previously.

func (CSOUND) UtilityDescription

func (csound CSOUND) UtilityDescription(utilName string) string

Get utility description. Return nil if the utility was not found, or it has no description, or an error occured.

func (CSOUND) Version

func (csound CSOUND) Version() string

Return the version number

func (CSOUND) WaitBarrier

func (csound CSOUND) WaitBarrier(barrier unsafe.Pointer) int

Wait on the thread barrier.

func (CSOUND) WaitThreadLock

func (csound CSOUND) WaitThreadLock(lock unsafe.Pointer, ms uint) int

Wait on the indicated monitor object for the indicated period. The function returns either when the monitor object is notified, or when the period has elapsed, whichever is sooner; in the first case, zero is returned.

If 'milliseconds' is zero and the object is not notified, the function will return immediately with a non-zero status.

func (CSOUND) WaitThreadLockNoTimeout

func (csound CSOUND) WaitThreadLockNoTimeout(lock unsafe.Pointer)

Wait on the indicated monitor object until it is notified. This function is similar to WaitThreadLock() with an infinite wait time, but may be more efficient.

func (CSOUND) WriteCircularBuffer

func (csound CSOUND) WriteCircularBuffer(circularBuffer unsafe.Pointer, inp []MYFLT,
	items int) int

Write to circular buffer

circular_buffer - pointer to an existing circular buffer
inp - buffer with at least items number of elements to be written into
      circular buffer
items - number of samples to be written

Returns the actual number of samples written (0 <= n <= items)

type ChannelHandler

type ChannelHandler func(csound CSOUND, channelName string,
	channelValue []MYFLT, channelType int)

type ControlChannelHints

type ControlChannelHints struct {
	Behav      int
	Dflt       MYFLT
	Min        MYFLT
	Max        MYFLT
	X          int
	Y          int
	Width      int
	Height     int
	Attributes string // This member must be set explicitly to NULL if not used
}

type ControlChannelInfo

type ControlChannelInfo struct {
	Name  string
	Type  int
	Hints ControlChannelHints
}

type CsRtAudioParams

type CsRtAudioParams struct {
	// contains filtered or unexported fields
}

type CscoreHandler

type CscoreHandler func(csound CSOUND)

type Cslanguage_t

type Cslanguage_t int
const (
	CSLANGUAGE_DEFAULT Cslanguage_t = iota
	CSLANGUAGE_AFRIKAANS
	CSLANGUAGE_ALBANIAN
	CSLANGUAGE_ARABIC
	CSLANGUAGE_ARMENIAN
	CSLANGUAGE_ASSAMESE
	CSLANGUAGE_AZERI
	CSLANGUAGE_BASQUE
	CSLANGUAGE_BELARUSIAN
	CSLANGUAGE_BENGALI
	CSLANGUAGE_BULGARIAN
	CSLANGUAGE_CATALAN
	CSLANGUAGE_CHINESE
	CSLANGUAGE_CROATIAN
	CSLANGUAGE_CZECH
	CSLANGUAGE_DANISH
	CSLANGUAGE_DUTCH
	CSLANGUAGE_ENGLISH_UK
	CSLANGUAGE_ENGLISH_US
	CSLANGUAGE_ESTONIAN
	CSLANGUAGE_FAEROESE
	CSLANGUAGE_FARSI
	CSLANGUAGE_FINNISH
	CSLANGUAGE_FRENCH
	CSLANGUAGE_GEORGIAN
	CSLANGUAGE_GERMAN
	CSLANGUAGE_GREEK
	CSLANGUAGE_GUJARATI
	CSLANGUAGE_HEBREW
	CSLANGUAGE_HINDI
	CSLANGUAGE_HUNGARIAN
	CSLANGUAGE_ICELANDIC
	CSLANGUAGE_INDONESIAN
	CSLANGUAGE_ITALIAN
	CSLANGUAGE_JAPANESE
	CSLANGUAGE_KANNADA
	CSLANGUAGE_KASHMIRI
	CSLANGUAGE_KAZAK
	CSLANGUAGE_KONKANI
	CSLANGUAGE_KOREAN
	CSLANGUAGE_LATVIAN
	CSLANGUAGE_LITHUANIAN
	CSLANGUAGE_MACEDONIAN
	CSLANGUAGE_MALAY
	CSLANGUAGE_MALAYALAM
	CSLANGUAGE_MANIPURI
	CSLANGUAGE_MARATHI
	CSLANGUAGE_NEPALI
	CSLANGUAGE_NORWEGIAN
	CSLANGUAGE_ORIYA
	CSLANGUAGE_POLISH
	CSLANGUAGE_PORTUGUESE
	CSLANGUAGE_PUNJABI
	CSLANGUAGE_ROMANIAN
	CSLANGUAGE_RUSSIAN
	CSLANGUAGE_SANSKRIT
	CSLANGUAGE_SERBIAN
	CSLANGUAGE_SINDHI
	CSLANGUAGE_SLOVAK
	CSLANGUAGE_SLOVENIAN
	CSLANGUAGE_SPANISH
	CSLANGUAGE_SWAHILI
	CSLANGUAGE_SWEDISH
	CSLANGUAGE_TAMIL
	CSLANGUAGE_TATAR
	CSLANGUAGE_TELUGU
	CSLANGUAGE_THAI
	CSLANGUAGE_TURKISH
	CSLANGUAGE_UKRAINIAN
	CSLANGUAGE_URDU
	CSLANGUAGE_UZBEK
	CSLANGUAGE_VIETNAMESE
	CSLANGUAGE_COLUMBIAN
)

List of languages

type CsoundAudioDevice

type CsoundAudioDevice struct {
	DeviceName string
	DeviceId   string
	RtModule   string
	MaxNchnls  int
	IsOutput   bool
}

func (CsoundAudioDevice) String

func (dev CsoundAudioDevice) String() string

type CsoundMidiDevice

type CsoundMidiDevice struct {
	DeviceName    string
	InterfaceName string
	DeviceId      string
	MidiModule    string
	IsOutput      bool
}

func (CsoundMidiDevice) String

func (dev CsoundMidiDevice) String() string

type CsoundParams

type CsoundParams struct {
	DebugMode            int32 // debug mode, 0 or 1
	BufferFrames         int32 // number of frames in in/out buffers
	HardwareBufferFrames int32 // ibid. hardware
	Displays             int32 // graph displays, 0 or 1
	AsciiGraphs          int32 // use ASCII graphs, 0 or 1
	PostscriptGraphs     int32 // use postscript graphs, 0 or 1
	MessageLevel         int32 // message printout control
	Tempo                int32 // tempo (sets Beatmode)
	RingBell             int32 // bell, 0 or 1
	UseCscore            int32 // use cscore for processing
	TerminateOnMidi      int32 // terminate performance at the end of midifile, 0 or 1
	HeartBeat            int32 // print heart beat, 0 or 1
	DeferGen01Load       int32 // defer GEN01 load, 0 or 1
	MidiKey              int32 // pfield to map midi key no
	MidiKeyCps           int32 // pfield to map midi key no as cps
	MidiKeyOct           int32 // pfield to map midi key no as oct
	MidiKeyPch           int32 // pfield to map midi key no as pch
	MidiVelocity         int32 // pfield to map midi velocity
	MidiVelocityAmp      int32 // pfield to map midi velocity as amplitude
	NoDefaultPaths       int32 // disable relative paths from files, 0 or 1
	NumberOfThreads      int32 // number of threads for multicore performance
	SyntaxCheckOnly      int32 // do not compile, only check syntax
	CsdLineCounts        int32 // csd line error reporting
	ComputeWeights       int32 // deprecated, kept for backwards comp.
	RealtimeMode         int32 // use realtime priority mode, 0 or 1
	SampleAccurate       int32 // use sample-level score event accuracy
	SampleRateOverride   MYFLT // overriding sample rate
	ControlRateOverride  MYFLT // overriding control rate
	NchnlsOverride       int32 // overriding number of out channels
	NchnlsIoverride      int32 // overriding number of in channels
	E0dbfsOverride       MYFLT // overriding 0dbfs
	Daemon               int32 // daemon mode
	KsmpsOverride        int32 // ksmps override
	FFT_library          int32 // fft_lib
}

type ExitGraphHandler

type ExitGraphHandler func(csound CSOUND) int32

type ExternalMidiErrorStringHandler

type ExternalMidiErrorStringHandler func(err int) string

type ExternalMidiInCloseHandler

type ExternalMidiInCloseHandler func(csound CSOUND, userData unsafe.Pointer) int32

type ExternalMidiInOpenHandler

type ExternalMidiInOpenHandler func(csound CSOUND, userData unsafe.Pointer, devName string) int32

type ExternalMidiOutCloseHandler

type ExternalMidiOutCloseHandler func(csound CSOUND, userData unsafe.Pointer) int32

type ExternalMidiOutOpenHandler

type ExternalMidiOutOpenHandler func(csound CSOUND, userData unsafe.Pointer, devName string) int32

type ExternalMidiReadHandler

type ExternalMidiReadHandler func(csound CSOUND, userData unsafe.Pointer, buf []uint8) int32

type ExternalMidiWriteHandler

type ExternalMidiWriteHandler func(csound CSOUND, userData unsafe.Pointer, buf []uint8) int32

type FileOpenHandler

type FileOpenHandler func(csound CSOUND, pathName string, fileType int, write, temp bool)

type GraphHandler

type GraphHandler func(csound CSOUND, windat unsafe.Pointer)

type MYFLT

type MYFLT float64

type MakeGraphHandler

type MakeGraphHandler func(csound CSOUND, windat unsafe.Pointer, name string)

type MidiDeviceListHandler

type MidiDeviceListHandler func(csound CSOUND, list *CsoundMidiDevice, isOutput bool) int

type NamedGen

type NamedGen struct {
	Name string
	Num  int
}

type OpcodeListEntry

type OpcodeListEntry struct {
	Opname  string
	Outypes string
	Intypes string
	Flags   int
}

type PVSDATEXT

type PVSDATEXT struct {
	Frame   []float32
	CStruct *C.PVSDATEXT
}

func NewPvsData

func NewPvsData(N, format, overlap, winsize int32) *PVSDATEXT

type PlayOpenHandler

type PlayOpenHandler func(csound CSOUND, parm *CsRtAudioParams) int32

type RecOpenHandler

type RecOpenHandler func(csound CSOUND, parm *CsRtAudioParams) int32

type RtCloseHandler

type RtCloseHandler func(csound CSOUND)

type RtPlayHandler

type RtPlayHandler func(csound CSOUND, outBuf []MYFLT)

type RtRecordHandler

type RtRecordHandler func(csound CSOUND, inBuf []MYFLT) int32

type SenseEventHandler

type SenseEventHandler func(csound CSOUND, userData unsafe.Pointer)

type TREE

type TREE struct {
	// contains filtered or unexported fields
}

type YieldHandler

type YieldHandler func(csound CSOUND) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL