spell-music / csound-expression Goto Github PK
View Code? Open in Web Editor NEWHaskell Framework for Electronic Music
Haskell Framework for Electronic Music
The documentation (Patches.md) says ".. way we can play the patches with real MIDI-device:"
dac $ mul 0.75 $ atMidi toneWheelOrgan
but on my machine this fails with
ALSA midi: Using all devices.
ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC2D0 failed: Device or resource busy
ALSA: error opening MIDI input device: 'hw:2,0'
ALSA midi: Error opening device: hw:2,0
ALSA midi: No devices found.
How is this supposed to work? I was expecting that some midi port shows up (e.g., in aplaymidi -l
) so that I can route signals there from qjackctl
.
(EDIT) some more data: I have a (USB) MIDI keyboard (Akai LPK 25) attached to the computer:
aplaymidi -l
Port Client name Port name
14:0 Midi Through Midi Through Port-0
24:0 LPK25 LPK25 MIDI
amidi -l
Dir Device Name
IO hw:2,0,0 LPK25 MIDI 1
But I am still getting:
dacBy (setMidiDevice "hw:2,0,0") $ osc 200
...
ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC2D0 failed: Device or resource busy
ALSA: error opening MIDI input device: 'hw:2,0,0'
When I execute cabal install csound-expression i get the followwing error message? What is going wrong? I'm still new to Haskell. I use Cabal version 1.16 if that helps.
src/Csound/IO.hs:115:25:
Overlapping instances for RenderCsd (SE a)
arising from a use of renderCsdBy' Matching instances: instance Sigs a => RenderCsd a -- Defined at src/Csound/IO.hs:93:31 instance Sigs a => RenderCsd (SE a) -- Defined at src/Csound/IO.hs:96:31 In the expression: renderCsdBy opt (fromSource a) In an equation for
renderCsdBy':
renderCsdBy opt a = renderCsdBy opt (fromSource a)
In the instance declaration for `RenderCsd (Source a)'
src/Csound/IO.hs:118:25:
Overlapping instances for RenderCsd (SE a)
arising from a use of renderCsdBy' Matching instances: instance Sigs a => RenderCsd a -- Defined at src/Csound/IO.hs:93:31 instance Sigs a => RenderCsd (SE a) -- Defined at src/Csound/IO.hs:96:31 In the expression: renderCsdBy opt (fromSourceSE a) In an equation for
renderCsdBy':
renderCsdBy opt a = renderCsdBy opt (fromSourceSE a)
In the instance declaration for `RenderCsd (Source (SE a))'
src/Csound/IO.hs:121:27:
Overlapping instances for RenderCsd (SE ())
arising from a use of renderCsdBy' Matching instances: instance RenderCsd (SE ()) -- Defined at src/Csound/IO.hs:90:30 instance Sigs a => RenderCsd a -- Defined at src/Csound/IO.hs:93:31 instance Sigs a => RenderCsd (SE a) -- Defined at src/Csound/IO.hs:96:31 In the expression: renderCsdBy opt In the expression: renderCsdBy opt $ do { (ui, _) <- unSource src; panel ui } In an equation for
renderCsdBy':
renderCsdBy opt src
= renderCsdBy opt
$ do { (ui, _) <- unSource src;
panel ui }
src/Csound/IO.hs:126:27:
Overlapping instances for RenderCsd (Source ())
arising from a use of renderCsdBy' Matching instances: instance Sigs a => RenderCsd a -- Defined at src/Csound/IO.hs:93:31 instance Sigs a => RenderCsd (Source a) -- Defined at src/Csound/IO.hs:114:31 instance RenderCsd (Source ()) -- Defined at src/Csound/IO.hs:120:30 In the expression: renderCsdBy opt (joinSource src) In an equation for
renderCsdBy':
renderCsdBy opt src = renderCsdBy opt (joinSource src)
In the instance declaration for `RenderCsd (Source (SE ()))'
Failed to install csound-expression-5.2.2
cabal: Error: some packages failed to install:
csound-expression-5.2.2 failed during the building phase. The exception was:
ExitFailure 1
I had to revert to the previous commit to compile. Errors:
src/Csound/Control/Instr.hs:90:5: Not in scope: ‘trigByName’
src/Csound/Control/Instr.hs:90:17: Not in scope: ‘trigByName_’
src/Csound/Control/Instr.hs:91:5: Not in scope: ‘trigByNameMidi’
src/Csound/Control/Instr.hs:91:21: Not in scope: ‘trigByNameMidi_’
Please, add CoreMidi
to Rtmidi
constructors. It's strange, but in documentaion of csound there's no word about this driver on MacOSX.
But here it is: http://en.flossmanuals.net/csound/c-configuring-midi
PS. Anton, thank you for your wonderfull software and quick fixes.
GUI specific code somehow slips to the audio code (it's invoked as subinstr).
Minimal example:
main = dac $ midiChooser [
("osc", onMsg $ onCps $ saw)
, ("instr", onMsg $ onCps $ mul (fades 0.2 0.2) . osc)] 1
Suprisingly it's true. It leads to bugs in the very simple programs like.
By some strange design decision the number of outputs in the subinstr
have to be
not greater than nchnls`. We use subinstr to return the signals from "dynamic" instruments,
for passsing the signals from child to parent:
> let guitar = fst $ loopSnd "StereoGuitarSample.wav"
> dac guitar
The csound proceeds with error:
INIT ERROR in instr 20: subinstr: number of output args greater than nchnls
ar0 ar1 subinstr.i 19
Consider substituting the subinstr
with reading from dynamically allocated channels.
At the moment, the gen :: Int -> [Double] -> Tab
function can't be used to define GEN30 because GEN30 needs a table number as main argument.
We can see it in the generated code:
kr1 = (..) ? 1 : 0
ir2 = (..) ? 2 : kr1
here kr1
should be ir1
(forced to i-rate)
Sometimes it fails to force the signal to control rate
and tries to convert the audio-rate signals to constants.
Concrete example:
> dac $ C.tibetan 8 0.1 (linseg [110, 5, 150])
Fails with
error: Unable to find opcode entry for 'downsamp' with matching argument types:
Found: i downsamp a
Line: 47
from file tmp.csd (1)
If we use uiPongy or uiRoom we can clearly see that the effects are duplicated.
If we have the stereo effect like this:
(a1, a2) = fx args
The rendering algorithm is going to use it twice. And it takes the left case from the first run and the second case from the second run:
(a1, a2) = fx args
... do something ..
(a3, a4) = fx args
... do something ..
process a1, a4
And a2
and a3
are dead ends. That's a bug,
I have here a computer where I needed a lot of experimenting until I found a way to play sound from csound-expression via jack:
dacBy (setJack "ce" <> setRates 48000 0 <> setBufs 0 2041 ) $ osc 300
where 2041
seems minimal. I have no idea what 0 0 2041
mean.
Perhaps this information is helpful for others.
Running dac $ mul (humanVal 0.1 sqrSeq [1, 0.5, 0.2, 0.1] 1) $ white
from Csound-Air-Envelope
give me the following error:
<interactive>:107:12-51:
Couldn't match type ‘Sig’ with ‘SE Sig’
Expected type: [Sig] -> Sig -> Sig
Actual type: HumanizeValueOut ([Sig] -> Sig -> Sig)
The function ‘humanVal’ is applied to four arguments,
but its type ‘Sig
-> ([Sig] -> Sig -> Sig) -> HumanizeValueOut ([Sig] -> Sig -> Sig)’
has only two
In the first argument of ‘mul’, namely
‘(humanVal 0.1 sqrSeq [1, 0.5, 0.2, 0.1] 1)’
In the expression: mul (humanVal 0.1 sqrSeq [1, 0.5, 0.2, 0.1] 1)
It would be nice to have the function:
choose :: [(sig, Sam)] -> Sam
or
choose :: [(sig, Sco)] -> Sco
for randomized choice between several scores/samples. So that it can be used with ordinary functions
like del/hor/mel. It opens the way to randomized composition which is so useful for the algorythmic composition
For example: if we try to play wav file in loop with the opcode diskin2
, it leads to error:
> let (a,b ) = ar2 $ diskin2 "sound.wav" 1 `withDs` [0, 1]
Teen.hs:8:60:
No instance for (Val (Sig, Sig)) arising from a use of `withDs'
Possible fix: add an instance declaration for (Val (Sig, Sig))
In the second argument of `($)', namely
`diskin2 (text "Teentaal.wav") 1 `withDs` [0, 1]'
Minimal example:
a second live example:
$ ghci
Prelude> :m +Csound.Base Csound.Patch
> dac $ atNote (orcSharc shAltoFlute) (0.5, 220)
A note is played.
Hit Ctrl+C
> dac $ atNote (dreamSharc shAltoFlute) (0.5, 220)
Csound complains then stops.
I'm on NixOS 19.09 and I'm thinking this is a system related issue; but in my case, any output doesn't work.
Repl:
λ> dac $ osc 300
0dBFS level = 32768.0
--Csound version 6.13 (double samples) Jan 1 1970
[commit: none]
libsndfile-1.0.28
UnifiedCSD: tmp.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
Elapsed time at end of orchestra compile: real: 0.001s, CPU: 0.001s
sorting score ...
... done
Elapsed time at end of score sort: real: 0.001s, CPU: 0.001s
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 256 sample-frame blocks
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
*** Cannot open device 'default' for audio input: Connection refused
Failed to initialise real time audio input
inactive allocs returned to freespace
end of score. overall amps: 0.00000
overall samples out of range: 0
1 errors in performance
Elapsed time at end of performance: real: 0.726s, CPU: 0.004s
*Main Lib Csound.Base
λ>
And I can see some logs related to PA:
Dec 15 16:27:54 quasar-nixos-tr pulseaudio[38142]: [pulseaudio] socket-server.c: bind(): Address already in use
Dec 15 16:27:54 quasar-nixos-tr pulseaudio[38142]: [pulseaudio] module.c: Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed.
Dec 15 16:27:54 quasar-nixos-tr pulseaudio[38142]: [pulseaudio] main.c: D-Bus name org.PulseAudio1 already taken.
Dec 15 16:27:54 quasar-nixos-tr pulseaudio[38139]: [pulseaudio] main.c: Daemon startup failed.
And I'm not sure how to debug this.
Any clues to what I might be doing wrong?
Edit: sound output works perfectly using other applications; Spotify, FF etc.
Another thing to note: I'm using a USB audio interface. I'm not sure if I need to specify special settings for that.
A follow up question: I'm assuming that csound talks to Alsa to route audio. Alsa routes this audio to some interface called 'default' on PA; which either doesn't exist or is not enabled. But in that case, the error message doesn't really agree with my hypothesis.
Is there something I can set in the options to route audio differently?
Hi. While trying to understand SE
, I was thinking - this should work without the Monad instance. Applicative is enough? See https://www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/ce/#what-can-we-do-with-results-of-actions
Deps:
- csound-expression-5.3.2@sha256:ae99c0581e179ebdf94dda796635f058865a3d9c286636981ce38f16a814879b,4430
- csound-expression-dynamic-0.3.3@sha256:03f99c095a1876fd1166ebf0f7e00834110d47765922774d625268c354c11c42,1375
- csound-catalog-0.7.3@sha256:f151ff49ae4f009174db60dd4114be25967d693edecea1462a17c399a8032e40,1731
- csound-sampler-0.0.9.0@sha256:068c18b12d449c8acbf488c79b53cfa8a7cfc6c6275b8231d76ec10e49c3a4a7,1294
- sharc-timbre-0.2@sha256:b6bc95680069e6962d683d1cc214045c5eea6277e7383cb99656c85bdcef822f,2725
- csound-expression-opcodes-0.0.4.0@sha256:9920f962790b8e58884914474a2c10719d685eaf6a5b14873001308b053901a6,1584
- csound-expression-typed-0.2.2.0@sha256:ae5e024b832d0f43694582734c557158d31942a8d33833e9251b4458df07422b,4113
- temporal-media-0.6.3@sha256:7a27d711a786c3dc9163433627e51efcc4b3fce3a947b71c29f3e388f37cae59,857
- data-fix-cse-0.0.2@sha256:18fcb64d0fe1866bf1032f3ca9c7b20d3702aa35f5a383f33c84de849bb18a88,972
- wl-pprint-1.2.1@sha256:aea676cff4a062d7d912149d270e33f5bb0c01b68a9db46ff13b438141ff4b7c,734
Relevant code:
kick = osc (100 * linloop [1, 0.1 * takt 1, 0, 0.9 * takt 1, 0])
snare =
at (hp 500 23) . mul (sqrSeq [0, 0, 1, 0, 0, 0, 0.5, 0.2] (syn 4)) $ pink
ampBpmKnobs maxBpm
= let
bpmKnob = uknob 1
ampKnob = uknob 0.5
instr = hlift2
$ \amp bpm -> setBpm (maxBpm * bpm) >> mul amp (return kick + snare)
in
dac (instr ampKnob bpmKnob)
Repro:
Turn the BPM knob all the way to 0
;
Output:
λ> ampBpmKnobs 180
0dBFS level = 32768.0
--Csound version 6.13 (double samples) Jan 1 1970
[commit: none]
libsndfile-1.0.28
UnifiedCSD: tmp.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
Elapsed time at end of orchestra compile: real: 0.002s, CPU: 0.002s
sorting score ...
... done
Elapsed time at end of score sort: real: 0.002s, CPU: 0.002s
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 256 sample-frame blocks
ALSA input: total buffer size: 1024, period size: 256
reading 512-byte blks of shorts from adc (RAW)
ALSA output: total buffer size: 1024, period size: 256
writing 256 sample blks of 64-bit floats to dac
SECTION 1:
ftable 2:
new alloc for instr 18:
WARNING: loop opcode: wrong argument count
new alloc for instr 20:
new alloc for instr 21:
WARNING: Division by zero
WARNING: Division by zero
WARNING: Division by zero
... (continues for many lines)
The kick stops playing; but the snare keeps playing when I bring the BPM back to non-zero.
This seems to be an issue where we're rendering something in csound that causes a div. by zero error; but at this stage I'm not sure what that is.
Right now all expressions that go into if-else blocks are executed.
For all branches. It's better to place the expressions in separate branches:
It should be:
if (cond) {
a1 = b1
res = a1
} else {
a2 = b2
res = a2
}
But right now it's
a1 = b1
a2 = b2
if (cond) {
res = a1
} else {
res = a2
}
tutorial/CsoundInstro.markdown, line 348
Hi! Nice Library! I'm going to hold a presentation about csound-expression and it would be nice to know, if there is a way to run csound-expression under Windows or Mac OS. For myself I'm using Ubuntu, but it would be interesting for the audience.
Thanks in advance for your answer!
Best regards
Christoph
Hi, I was writing this https://www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/ce/ perhaps you want to use it in some way - provided the contents is correct.
When I use dacBy (setJack "ce" <> ...)
, ports ce:output1/2
are created, and connect to system:playback_1/2
. That's fine, I hear the sound.
But for (remote) teaching, I need connections to another port as well (PulseAudio JACK Source:front-left/right
) because that's being used by the video conference software (BBB, running in the browser, using WebRTC).
I can manually make that connection in qjackctl
but that's inconvenient (have to do it each time I evaluate an expression from ghci
).
I thought that something like this would help
dacBy (setJack "ce" <> setRates 48000 256 <> setBufs 2048 4096 ) $ do
{ jackoAudioOutConnect "dac:ce:output1" "dac:PulseAudio JACK Source:front-left"
; (0.05 *) $ at fromMono $ at (mlp (400 * uosc 1) 0.7) white
}
but I am getting
csound command: Segmentation fault
In the instant control stractures we can not use a-rates. So we force all the components to become k-rate. But conversion is pure and can be placed anywhere (in theory). but in practice it have to be placed before instant controls like:
if (smth happens) then
...
else
...
endif
Sometimes in the generated code a2k-rate conversions leak in the branches.
if (smth happens) then
...
kr11 = ar12
....
else
...
endif
They should be rendered before the if
-statement
As I understand, number of output channels nchnls
is calculated automatically by Sig Tuple length.
Is it possible to specify nchnls_i
value for number of input channels?
In following the tutorial there are times when you are using a virtual keyboard or midi controller for input. On macOs I have used the installer available from the latest version of csound 16.5.0 but whenever I run examples in ghci I get a blank window like
However, if you just randomly click around in this blank window, you can discover that the keys or sliders are actually working, in the sense that you can still create or manipulate sound. As far as I can tell, the appropriate flags are being set:
...
Creating score
rtaudio: PortAudio module enabled ...
using callback interface
rtmidi: PortMIDI module enabled
...
I wonder if it has something to do with the release note:
Starting from this release, no third-party graphic frontends are shipped with the installation packages on MacOs and Windows.
Does anyone else have this problem or a solution for it?
Cool project! I would love to try it out, however it does not build for me with 7.10.1:
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.1
$ cabal sandbox init
Writing a default package environment file to
/Users/pchiusano/Dropbox/projects/emusic/cabal.sandbox.config
Creating a new sandbox at
/Users/pchiusano/Dropbox/projects/emusic/.cabal-sandbox
$ cabal install csound-expression-4.8.2
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: csound-expression-4.8.2 (user goal)
trying: base-4.8.0.0/installed-901... (dependency of csound-expression-4.8.2)
trying: csound-expression-typed-0.0.7.7 (dependency of
csound-expression-4.8.2)
next goal: stable-maps (dependency of csound-expression-typed-0.0.7.7)
rejecting: stable-maps-0.0.5, 0.0.4, 0.0.3.3 (conflict: base =>
ghc-prim==0.4.0.0/installed-7c9..., stable-maps => ghc-prim>=0.2 && <0.4)
rejecting: stable-maps-0.0.3.2, 0.0.3.1, 0.0.3, 0.0.2, 0.0.1 (conflict:
csound-expression-typed => stable-maps>=0.0.3.3)
Dependency tree exhaustively searched.
Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
All right, let's try with --allow-newer
:
$ cabal install csound-expression-4.8.2 --allow-newer
...
Building csound-expression-typed-0.0.7.7...
Preprocessing library csound-expression-typed-0.0.7.7...
[ 1 of 32] Compiling Csound.Typed.Gui.BoxModel ( src/Csound/Typed/Gui/BoxModel.hs, dist/dist-sandbox-ca343f8f/build/Csound/Typed/Gui/BoxModel.o )
src/Csound/Typed/Gui/BoxModel.hs:58:10:
No instance for (Applicative (Scene ctx))
arising from the superclasses of an instance declaration
In the instance declaration for ‘Monad (Scene ctx)’
Failed to install csound-expression-typed-0.0.7.7
Updating documentation index /Users/pchiusano/Library/Haskell/doc/index.html
cabal: Error: some packages failed to install:
csound-expression-4.8.2 depends on csound-expression-typed-0.0.7.7 which
failed to install.
csound-expression-opcodes-0.0.3 depends on csound-expression-typed-0.0.7.7
which failed to install.
csound-expression-typed-0.0.7.7 failed during the building phase. The
exception was:
ExitFailure 1
Hi,
Incidentally, thanks for creating this fantastic library... made my day to find it just as I was about to learn csound.
As I went through the docs, I discovered strange problem related to widgets not appearing: when I test any of the gui code on csound-expression
ver 5.3.4 on OS X Mojave (10.14.6) with ghc v version 8.4.3 I get no errors with compilation and I can run the demo with a window appearing but no widgets showing.
Interestingly, the widget are created and functional (sound is generated when I click on them) but they just don't appear. I can even print the window and they are shown.
Please see the following sequence and attachments for a reproducible demo of the problem:
module Main where
import Csound.Base
import Csound.Sam
a1 = infSig1 $ osc 220
a2 = infSig1 $ osc 330
main = dac $ mul 0.5 $ lift1 (runSam 120) $ sim 4 [("220", a1), ("330", a2)]
$ ghc --make demo.hs
ghc --make demo.hs
[1 of 1] Compiling Main ( demo.hs, demo.o )
Linking demo ...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
$./demo
see the attached screenshot.jpg for what appears after running the above code
When I click on parts of the window the sound is generated as expected. Even more strangely, when the window is printed into a pdf the widgets are show in the print out. (see attached)
Merry Christmas,
I am constantly running into Segmentation faults with csound-expression.
dac $ osc 440
is working correctly, putting the sound on the speakers but pretty much everything I try with scores seems to trigger the segmentation fault for me. Taken from the Readme here:
> instr x = return $ osc $ sig x
> dac $ mix $ sco instr (temp 440)
Already gives me the following:
0dBFS level = 32768.0
--Csound version 6.10 (double samples) 2018-01-27
[commit: none]
libsndfile-1.0.28
UnifiedCSD: tmp.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
csound command: Segmentation fault
end of score. overall amps: 0.0
overall samples out of range: 0
0 errors in performance
Elapsed time at end of performance: real: 0.252s, CPU: 0.002s
Prelude Csound.Base>
ghci version: 8.6.2
csound-expression: 5.3.2
OS: ubuntu 64bit
I also tried example files from this repo and they failed too. I try to understand the problem, but can't find the cause for this problem. Any possible solutions or root causes you may know?
I think it would be good if the docs/tutorial explained the rationale for using type Sig
vs SE Sig
,
and what are the implications for the user (how should my programs look) and for the engine (what happens on the csound back-end).
In both cases, a signal represents a mapping from time to value (amplitude)? But we never get to see the "current time/value" and always combine functions "point-free". Unless we use '>>=', see below.
Also, the Num
instances somehow obfuscate the issue.
E.g., I can do
dac $ osc 1 * osc 400 -- both of type Sig
dac $ white * white -- both of type SE Sig
but not
dac $ white * osc 1
I can swap terms and use applicative notation
dac $ (osc 1 *) <$> white
Now, about dependencies in parameters: Say I want an osc
whose frequency is random.
dac $ (200 * (2 + rndh 4)) >>= ( return . osc )
is this how it's supposed to look?
The code to smoothly update frequency for an
always on instrument with midi messages:
module Main where
import Csound.Base
setFreq :: SERef Sig -> Msg -> SE ()
setFreq ref msg = writeSERef ref (sig cps)
where (amp, cps) = ampCps msg
instr :: Sig -> Sig
instr cps = osc (portk cps 3)
main = vdac $ do
freqRef <- newSERef 0
midi_ $ setFreq freqRef
cps <- readSERef freqRef
return $ instr cps
Alas, this code doesn't work at the moment, because all mutables now are local to the instruments. But top level mutables should be rendered as global variables.
The same code is rendered. But produced results are different. Sometimes it skips the instrument.
The strange thing is that naming of the arguments changes from run to run.
The problem is reported on GHC-7.10.3
I can't find the source on github/google either. There's no apparent way to compile the latest commit (e78943f).
The Introduction for Haskellers talks about the CsdEventList
type. However, since the 4.7 version,
The low level
CsdEventList
is substituted with more advanced and flexible typeSco
.
Could you update the documentation?
Hello!
I believe that a mailing list is a great way to cultivate a community around an exciting piece of software, such as this one. Have you considered starting one?
Cheers,
Louis
Hi. When I use jack output, I am getting a ton of messages each time I call dacBy
from ghci
dacBy (setJack "ce" <> setRates 48000 128 <> setBufs 2048 4096 ) $ (0.05 *) $ fromMono $ osc 200
0dBFS level = 32768.0
--Csound version 6.15 (double samples) Aug 24 2020
[commit: none]
libsndfile-1.0.28
WARNING: could not open library '/usr/lib64/csound/plugins-6.0/libpy.so' (/usr/lib64/csound/plugins-6.0/libpy.so: undefined symbol: PyFile_AsFile)
UnifiedCSD: tmp.csd
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
rtaudio: JACK module enabled
rtmidi: ALSA Raw MIDI module enabled
Elapsed time at end of orchestra compile: real: 0.006s, CPU: 0.006s
sorting score ...
... done
Elapsed time at end of score sort: real: 0.006s, CPU: 0.006s
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 2048 sample-frame blocks
reading 8192-byte blks of shorts from adc (RAW)
Jack: JackClient::ClientNotify ref = 6 name = ce-01 notify = 0
Jack: JackClient::AddClient name = ce-01, ref = 6
Jack: JackLinuxFutex::Connect name = jack_sem.1000_default_ce-01
Jack: JackClient::kAddClient fName = ce name = ce-01
Jack: JackClient::ClientNotify ref = 5 name = ce notify = 18
Jack: JackClient::ClientNotify ref = 5 name = ce notify = 18
Jack: JackClient::SetupDriverSync driver sem in flush mode
Jack: JackLinuxFutex::Connect name = jack_sem.1000_default_ce-01
Jack: Clock source : system clock via clock_gettime
Jack: JackLibClient::Open name = ce-01 refnum = 6
system sr: 48000.000000
...
new alloc for instr 18:
new alloc for instr 20:
new alloc for instr 21:
WARNING: rtjack: xrun in real time audio
Jack: JackClient::ClientNotify ref = 5 name = ce notify = 18
Jack: JackClient::ClientNotify ref = 5 name = ce notify = 18
^C
csound command: Interrupt
csound command: Terminated
Interrupted.
it's no different when I add <> noTrace
.
I don't want these messages - I just want to see the expression that I just typed in ghci.
I understand that it's good to have the messages available (e.g., for debugging), and I understand that there are use cases where the messages don't hurt (e.g., when you mainly want to work with a GUI, not the console). But my application is for teaching - just evaluating an expression: while the sound is playing, students should study the expression. I can get this by scrolling back several pages - that's entirely possible, but inconvenient.
I type an example from the tutorial in ghci:
import Csound.Base
let n1 = button "330"
let n2 = button "440"
let instr x = return $ fades 0.1 0.5 * osc x
let go x evt = sched (const $ instr x) (withDur 2 evt)
dac $ do { (g1, p1) <- n1;(g2, p2) <- n2;panel $ hor [g1, g2];return $ mul 0.25 $ go 330 p1 + go 440 p2 }
result:
0dBFS level = 32768.0
Csound version 6.04 (double samples) Nov 28 2014
libsndfile-1.0.25
UnifiedCSD: tmp.csd
STARTING FILE
Creating options
Creating orchestra
Creating score
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
error: syntax error, unexpected STRING_TOKEN (token """") from file tmp.csd (1)
line 25:
>>>FLpanel "" <<<
Unexpected untyped word FLpanel when expecting a variable
Parsing failed due to invalid input!
Stopping on parser failure
cannot compile orchestra
end of score. overall amps: 0.0
overall samples out of range: 0
1 errors in performance
Elapsed time at end of performance: real: 0.002s, CPU: 0.001s
(the basic dac $ osc 440
is working.)
I found that mel $ repeat ...
does not work (it is type-correct, but it gives stack overflow)
mix $ sco (\ f -> return $ osc $ sig f ) $ mel $ repeat $ mel [ temp 300, rest 1 ]
On reason is implementation (mel
uses foldl1
, at least the default implementation does, https://github.com/spell-music/temporal-media/blob/master/src/Temporal/Class.hs#L24 ) but if I use
... foldr1 (+:+) $ repeat ...
it's still the same (stack overflow).
I guess that each Track Sig D
object must have finite duration?
And this is because it can contain only a finite number of notes since they will be written to the csound expression?
Does csound have some "loop" operator? (we construct some finite object, and csound loops over it)
On Fedora 35, with pipewire for audio routing:
I wanted to apply #61 (comment) but is does no longer work.
Standard operation is fine: When I just run dac $ osc 300
, output ports csound:output_FL
csound:output_FR
do appear (visible with jack_lsp
, and in qjackctl
). I can connect them manually from the command line jack_connect 'csound:output_FL' 'Firefox:input_FL'
.
But when I try this connection from within c-s-e, I get
Prelude Csound.Base> dacBy (setJackConnect [("csound:output_FL","Firefox:input_FL")]) $ osc 300
ERROR csound:output_FL not a valid port
^C
same with extra single quotes, and your suggested at (delaySig 1)
.
When I try to just re-name the output,
Prelude Csound.Base> dacBy (setJack "cse") $ osc 300
I expect it to produce sound as in the standard case, just with renamed csound ports. But I hear no sound at all, and there are no ports visible.
Hi Anton, I am again using csound-expression in my lecture. Because COVID, we switch to remote teaching, right this week, and all sorts of technical problems re-appear ... This thing here is not a blocker, as I can connect the ports manually, but that's quite inconvenient. What can I do to debug the above behaviour?
let eq_levels = zip (iterate id 0.5) $ fmap (*100) [1,4,16,64]
dac $ equalizer eq_levels 1 $ saw 1000
results in this csound (csound-6.04) error:
INIT ERROR in instr 18: table: index type inconsistent with output
ar0 table.a 1.0 1 1.0 0 0
B 0.000 - note deleted. i18 had 1 init errors
it happens because the first argument for table
should be the same as a return type.
http://www.csounds.com/manual/html/table.html
if we use:
dac $ equalizer eq_levels (upsamp 1) $ saw 1000
csound error disappered, but there's another problem - no sound at all.
As I think, a something strange happens in defineTabArgs
function of GEN16 routine:
substGen16 durs xs = case (durs, xs) of
([], as) -> as
(_, []) -> []
(d:ds, valN:_:typeN:rest) -> valN : d : (typeN * d) : substGen16 ds rest
(_, _) -> xs
Are you shure that 3rd argument should be multiplied by d: (typeN * d)
?
$ dacBy (mconcat [setDacBy "3"]) $ osc 440
results in outputting to default device (1), because csound command line options have higher priority then in <CsdOptions>
Example:
module Main where
import Csound.Base
evts :: Evt D
evts = fmap (\x -> (x + 2) / 9) $ filterE (<=* 7) $ range (0, 41) $ metroE (1000 / 17)
proc :: Sig -> Sig
proc x = (* 0.5) $ hp 4000 $ sum
[ 100 * sum
[ bp 4500 1200 y
, bp 4550 1200 y
, bp 4600 1200 y
]
, 42 * bp 9000 500 y
]
where y = lp 1000 x
pulse :: D -> Sig
pulse amp = sig amp * linseg [0, 0.1/1000, 1, 0.1/1000, 0, 1, 0]
main = dac $ do
asig <- schedule pulse $ fmap (\amp -> (0.2, amp)) evts
return $ proc asig
Inside the if-then-else branch state of the event stream is forced to the i-rate, so no update happens.
Hello!
So with Supercollider (and more interestingly, the Clojure environment Overtone), one can write, evaluate, and modify synths lives in order to create music and perform live. Writing code in an editor, and then sending it to a process making the bleeps and bloops. This is something I'm very interested in!
The Csound wikipedia page implies that this is now possible with Csound6, though I can find little more information beyond that. Is it possible to do this with csound-expression
Cheers,
Louis
Right now unique names are assigned to all variables. But every new name means more memory to store the values. It's better to reuse variables (or make liveness analysis).
The expression
vdac $ midi $ onMsg (fromMono . osc)
Leads to duplication of the midi instrument. No sound is produced.
The example from the tutorial
vdac $ midi $ onMsg $ \x -> saw (x + 150 * leg 2 2 0.5 1)
lead to this error
error: -+rtmidi='virtual': unknown module
*** error opening MIDI in device: -1 (Unknown MIDI error)
I needed some time before I realized that this is because of a missing csound module. I fixed it by installing
csound-virtual-keyboard
(on Fedora).
... so I cannot run examples/Live.hs (also, celtic and ocean that you posted on haskell-cafe)
other things in examples/ are working fine.
Proposed solutions by Henning Thielemann
How about specifying 'base >=4.6' in the cabal file?
I think you have to fix csound-expression-4.1.0, e.g. by replacing 'catch'
by catchIOError from System.IO.Error. If you do so, you should increase
the version number of csound-expression-4.1.0 to e.g.
csound-expression-4.1.0.0.1 in order to avoid conflicts with new versions
on Hackage. You may access the package content by
catchIOError exists since GHC-7.2.
The second is prefered!
With a ghcup install 8.4.4 on macOS catalina 10.15.7 and cabal version 3.4.0.0 I get the following build failure after trying cabal update && cabal install csound-expression
:
Failed to build csound-expression-dynamic-0.3.7.
Build log (
/Users/sa/.cabal/logs/ghc-8.4.4/csnd-xprssn-dynmc-0.3.7-27fe7c14.log ):
Warning: csound-expression-dynamic.cabal:3:23: Packages with 'cabal-version:
1.12' or later should specify a specific version of the Cabal spec of the form
'cabal-version: x.y'. Use 'cabal-version: 1.22'.
Configuring library for csound-expression-dynamic-0.3.7..
clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
Preprocessing library for csound-expression-dynamic-0.3.7..
Building library for csound-expression-dynamic-0.3.7..
[ 1 of 15] Compiling Csound.Dynamic.Tfm.DeduceTypes ( src/Csound/Dynamic/Tfm/DeduceTypes.hs, dist/build/Csound/Dynamic/Tfm/DeduceTypes.o )
[ 2 of 15] Compiling Csound.Dynamic.Tfm.UnfoldMultiOuts ( src/Csound/Dynamic/Tfm/UnfoldMultiOuts.hs, dist/build/Csound/Dynamic/Tfm/UnfoldMultiOuts.o )
[ 3 of 15] Compiling Csound.Dynamic.Types.Exp ( src/Csound/Dynamic/Types/Exp.hs, dist/build/Csound/Dynamic/Types/Exp.o )
src/Csound/Dynamic/Types/Exp.hs:396:10: error:
Duplicate instance declarations:
instance Hashable1 IM.IntMap
-- Defined at src/Csound/Dynamic/Types/Exp.hs:396:10
instance Hashable1 IM.IntMap
-- Defined in ‘hashable-1.3.4.1:Data.Hashable.Class’
|
396 | instance Hashable1 IM.IntMap
| ^^^^^^^^^^^^^^^^^^^
cabal: Failed to build csound-expression-dynamic-0.3.7 (which is required by
csound-expression-5.4.1). See the build log above for details.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.