Csound Help

#1

I’m trying to get started with Csound, but I’m having an issue with actually being able to hear anything.
My .csd is lifted from Csound’s Get Started page (Section: ‘Your First Synthesizer’), and is as follows:

<CsoundSynthesizer>
<CsInstruments>

instr 1
aOut vco2 1, p4
out aOut
endin

</CsInstruments>
<CsScore>
i1 0 1 100
i1 1 1 200
i1 2 1 300
</CsScore>
</CsoundSynthesizer>

I’ve tried running the .csd with csound -odac xxxx.csd and in non-realtime mode with just csound xxxx.csd. As I understand it, ‘dac’ should just use the default soundcard. However, no sound comes out. Equally frustratingly, just running csound xxxx.csd produces test.wav – however when I play this file either with sox or my default music player just results in sullen silence.

aplay -l Results:
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: STAC9205 Analog [STAC9205 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: STAC9205 Digital [STAC9205 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0```
screenfetch System Details:

(Complete with unnecessary info)

OS: elementary OS 5.0 juno
Kernel: x86_64 Linux 4.15.0-47-generic
Uptime: 1h 2m
Packages: 2185
Shell: bash 4.4.19
Resolution: 1440x900
DE: GNOME 
WM: Mutter(Gala)
WM Theme: elementary
GTK Theme: elementary [GTK2/3]
Icon Theme: elementary
Font: Open Sans 9
CPU: Intel Core2 Duo T7500 @ 2x 2.201GHz
GPU: GeForce 8600M GT
RAM: 1299MiB / 3943MiB
#2

You forgot the start… It should be declared samplerate and channels.

It should be something like this:

<CsoundSynthesizer>

<CsOptions>

	; Select audio/midi flags here according to platform
	-odac     ;;;realtime audio out
	;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
	; For Non-realtime ouput leave only the line below:
	 -o filename.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;
	; SETTINGS
	;
	; sr -> samplerate
	; kr -> controlrate
	; ksmps -> sr/kr
	; nchnls -> number of channels
	; 0dbfs -> max amplitude (0 -> 1) if 0dbfs = 1
	;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	sr=96000
	kr=9600
	ksmps = 10
	nchnls=2
	; amp is 0.0 -> 1.0
	0dbfs=1

Edit: Forgot to explain.

P.S: High Five for using GNU/Linux!

1 Like
#3

So are those settings at the top of <CsInstruments> absolutely mandatory? Does Csound not have default values for them?

Edit: I see the part where they explain the header now. Silly me. :man_facepalming:

#4

As they stated in the following link:

https://csound.com/get-started.html#csound-syntax

<CsOptions>
;this section tells Csound how to interact with various devices and hardware
</CsOptions>
#5

there are a couple of options missing:

sr = 44100
nchnls = 2
0dbfs = 1

put them inside CsInstruments, before any instrument.
The most important is 0dbfs, telling csound what is the max volume. The default, for historical reason, is 32768 (you can see in the csound output “0dBFS level = 32768.0”). Without that line, vco2 volume is 1/32000 of the max volume.

Also, setting nchnls to 2 makes it stereo, so you also have to change “out aOut” to “outs aOut, aOut”. This should work, both with -odac and without:

<CsoundSynthesizer>
<CsInstruments> 
sr = 44100
nchnls = 2
0dbfs = 1
                                                                                     
instr 1
  aOut vco2 1, p4
  outs aOut, aOut
endin

</CsInstruments>
<CsScore>
i1 0 1 100
i1 1 1 200
i1 2 1 300
</CsScore>
</CsoundSynthesizer>
2 Likes
#6

Thanks both for giving me a hand, It’s now working completely as expected :+1:
Also, am I imagining things or is there an online Csound IDE? I think I used one but DuckDuckGo searches are bringing up nothing.

1 Like
#7

i found this: https://live.csound.com/ but it’s not working in my browser…

Try an editor like csoundqt

#8

There is an Android app for Csound (maintained by myself) here: https://play.google.com/store/apps/details?id=com.csounds.Csound6&hl=en_US (new version coming very soon).

Csound runs on various SoCs including Raspberry Pi and Bela (https://blog.bela.io/2019/05/03/bela-learn-csound/),.

Csound runs as a WebAssembly binary in current browsers.

It is reasonably easy to build Csound for any system that supports a C compiler and libsndfile.

If you are on Linux, OS X, or Windows CsoundQt is a good way to get started, it comes with a bunch of examples.

There are C, C++, JavaScript, Python, Java, Common Lisp, Lua, and LuaJIT bindings for Csound.

Regards,
Mike