Skip to content

nchnls_hw

Returns the number of audio channels in the underlying hardware.

This does not necessarily correspond to the number of channels used by Csound (set by nchnls and nchnls_i).

Syntax

idacc, iadcc nchnls_hw

Initialization

On init-pass idacc will contain the number of channels in the output device, and iadcc, the number of input channels. These will correspond to the currently selected/in-use hardware devices.

Examples

Here is an example of the nchnls_hw opcode. It uses the file nchnls_hw.csd.

Example of the nchnls_hw opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
-iadc    ;;;realtime audio in
</CsOptions>
<CsInstruments>
; by Menno Knevel - 2024

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr 1 

idacc,iadcc nchnls_hw
prints "\non this machine:"
prints "\nnumber of outputs = %d\n", idacc
prints  "number of inputs = %d\n\n", iadcc

endin

</CsInstruments>
<CsScore>
i1 0 0
e
</CsScore>
</CsoundSynthesizer>

The output should include lines like these:

on this machine:
number of outputs = 32
number of inputs = 32

See also

Miscellaneous opcodes

Credits

Author: Victor Lazzarini
2016

In version 6.07