Csound Csound-dev Csound-tekno Search About

[Csnd] Announce: temporal-csound, csound-expression - Libraries to make Csound music with Haskell

Date2014-03-27 14:28
FromAnton Kholomiov
Subject[Csnd] Announce: temporal-csound, csound-expression - Libraries to make Csound music with Haskell
Is there any Haskellers out there?

I'm glad to announce the release of the two libraries
to make Csound music with haskell. Haskell is a most popular purely functional programming language.

csound-expression [1] - embeds Csound in Haskell.
With it you can get the powerfull sound units and (from Csound)
powerfull tools for abstraction (from Haskell) like higher-order
functions, functional data structures, modules and more.

You can just type in the haskell interpreter:

> dac $ osc 440

And hear the sound in the speakers.

To apply an envelope:

> dac $ linseg [0, 1, 1, 3, 0] * osc 440

To apply an lfo and use band-limited sawtooth:

> dac $ linseg [0, 1, 1, 3, 0] * saw (440 * (1 + 0.05 * osc 5))

To trigger instruments with midi (uses functions from temporal-csound package)

> dac $ mul 0.2 $ largeHall $ onMidi stringPad

We can play an mp3 right in the REPL like this

> dac $ ar2 $ mp3in $ text "/home/anton/listen/The Kinks-Waterloo Sunset.mp3"


The temporal-csound [2] library joins the forces of the packages
temporal-music-notation and csound-expression.
The former package gives you handy primitives to arrange
 the events in sequences (like parallel or sequential composition,
the tempo change, standard names for notes and durations)
and the later is used for creation of musical timbres or
software synthesizers.

It defines standard note representation that let's you invoke csound instruments with notes defined in the package temporal-music-notation.

Also this library provides you with some cool instruments to try the things out.

Library strives to be very simple. For example, to trigger the instrument with virtual midi-device is as simple as (in ghci with loaded modules Csound and Csound.Patch)

~~~
Csound Csound.Patch> vdac $ mul 0.2 $ largeHall $ onMidi stringPad

~~~
If you have a connected hardware midi-device you can just type:

~~~
Csound Csound.Patch> dac $ mul 0.2 $ largeHall $ onMidi stringPad

~~~

And you are ready to go. To play a C-major chord just do:

~~~
Csound Csound.Patch> dac $ mul 0.2 $ magicCave $ mix $ notes vibraphone2 $ mel [c, e, g, high c, rest 15]

~~~

Here we send the output to speakers (dac or vdac), scale the signal to make it quiter (mul), place the signal in some room with reverberation (largeHall or magicCave), listen to midi events (onMidi or onMidin for a midi on the given channel) or get the signal from scores (mix), trigger the csound instrument (stringPad or vibraphone2) on events (notes) and construct the events in sequence (mel). Events include notes (c, e, g - C major) and rests (rest).

WARNING: the library works best within ghci. The real-time sound rendering function dac spawns a child process in the background which may continue to execute after you stop the main process that runs the programm. It's not so in vim but it happens in the Sublime Editor and when you invoke runhaskell. So the best is to write you program in the separate file and then load it in the ghci and invoke the function main (which runs the sound rendering with the function dac).

[1] http://hackage.haskell.org/package/csound-expression
[2] http://hackage.haskell.org/package/temporal-csound-0.3.0


Cheers,
Anton


Date2014-03-27 15:06
FromVictor Lazzarini
SubjectRe: [Csnd] Announce: temporal-csound,
That looks really nice, thanks for doing it.
========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 27 Mar 2014, at 14:28, Anton Kholomiov  wrote:

> Is there any Haskellers out there? 
> 
> I'm glad to announce the release of the two libraries
> to make Csound music with haskell. Haskell is a most popular purely functional programming language.
> 
> csound-expression [1] - embeds Csound in Haskell. 
> With it you can get the powerfull sound units and (from Csound)
> powerfull tools for abstraction (from Haskell) like higher-order
> functions, functional data structures, modules and more.
> 
> You can just type in the haskell interpreter: 
> 
> > dac $ osc 440
> 
> And hear the sound in the speakers.
> 
> To apply an envelope:
> 
> > dac $ linseg [0, 1, 1, 3, 0] * osc 440
> 
> To apply an lfo and use band-limited sawtooth:
> 
> > dac $ linseg [0, 1, 1, 3, 0] * saw (440 * (1 + 0.05 * osc 5))
> 
> To trigger instruments with midi (uses functions from temporal-csound package)
> 
> > dac $ mul 0.2 $ largeHall $ onMidi stringPad
> 
> We can play an mp3 right in the REPL like this
> 
> > dac $ ar2 $ mp3in $ text "/home/anton/listen/The Kinks-Waterloo Sunset.mp3"
> 
> 
> For more info on csound-expression see 
> https://github.com/anton-k/csound-expression/blob/master/tutorial/QuickStart.markdown
> 
> The temporal-csound [2] library joins the forces of the packages 
> temporal-music-notation and csound-expression. 
> The former package gives you handy primitives to arrange
>  the events in sequences (like parallel or sequential composition,
> the tempo change, standard names for notes and durations) 
> and the later is used for creation of musical timbres or 
> software synthesizers.
> 
> It defines standard note representation that let's you invoke csound instruments with notes defined in the package temporal-music-notation.
> 
> Also this library provides you with some cool instruments to try the things out.
> 
> Library strives to be very simple. For example, to trigger the instrument with virtual midi-device is as simple as (in ghci with loaded modules Csound and Csound.Patch)
> 
> ~~~
> Csound Csound.Patch> vdac $ mul 0.2 $ largeHall $ onMidi stringPad
> 
> 
> ~~~
> If you have a connected hardware midi-device you can just type: 
> 
> ~~~
> Csound Csound.Patch> dac $ mul 0.2 $ largeHall $ onMidi stringPad
> 
> 
> ~~~
> 
> And you are ready to go. To play a C-major chord just do: 
> 
> ~~~
> Csound Csound.Patch> dac $ mul 0.2 $ magicCave $ mix $ notes vibraphone2 $ mel [c, e, g, high c, rest 15]
> 
> 
> ~~~
> 
> Here we send the output to speakers (dac or vdac), scale the signal to make it quiter (mul), place the signal in some room with reverberation (largeHall or magicCave), listen to midi events (onMidi or onMidin for a midi on the given channel) or get the signal from scores (mix), trigger the csound instrument (stringPad or vibraphone2) on events (notes) and construct the events in sequence (mel). Events include notes (c, e, g - C major) and rests (rest). 
> 
> WARNING: the library works best within ghci. The real-time sound rendering function dac spawns a child process in the background which may continue to execute after you stop the main process that runs the programm. It's not so in vim but it happens in the Sublime Editor and when you invoke runhaskell. So the best is to write you program in the separate file and then load it in the ghci and invoke the function main (which runs the sound rendering with the function dac). 
> 
> [1] http://hackage.haskell.org/package/csound-expression
> [2] http://hackage.haskell.org/package/temporal-csound-0.3.0
> 
> On github:
> 
> [3] https://github.com/anton-k/csound-expression
> [4] https://github.com/anton-k/temporal-csound
> 
> Cheers,
> Anton
> 



Send bugs reports to the Sourceforge bug trackers
csound6:
            https://sourceforge.net/p/csound/tickets/
csound5:
            https://sourceforge.net/p/csound/bugs/
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"