User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

command line music making

Mon Jun 04, 2012 11:48 pm

I am not sure if this the right forum, since I am a linux power user, but pi beginner.

I am wondering if there is a command line music making software that will work on the pi. Csound will probably work, and there are others like supercolider which I doubt will work or chuck.

This is the extent of my knowledge for command line music making and wondering if anyone else has experience or know of other system that could be used on the pi!

timr
Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: command line music making

Sat Jun 09, 2012 3:51 pm

If it works well enough, chuck (http://chuck.cs.princeton.edu/) will suit my needs.
I have concerns about the fp performance, but I won't know until I get my real Pi. It runs under a qemu emulation with a debian image, but I get no sound. I'm not going to say whether that's a problem until I get the real hardware.
The plan is to have chuck generate the audio, with a python script controlling it via OSC events.

tim

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Mon Jun 11, 2012 4:21 pm

yes I've seen chuck but wondered if it was compiled (or compilable ) with arm ? It seems quite better alternative than csound (even with pyton library). Supercollider is another one that I would love to port to arm...

for the sound (from the wiki:
http://elinux.org/R-Pi_Troubleshooting

Sound does not work at all, or in some applications

Sound is disabled by default because the ALSA sound driver is still "alpha" (not fully tested) on the R-Pi. To try out sound, from the command prompt before "startx", type

sudo apt-get install alsa-utils

sudo modprobe snd_bcm2835

sudo aplay /usr/share/sounds/alsa/Front_Center.wav

By default output will be automatic (hdmi if hdmi supports audio, otherwise analogue). You can force it with:

sudo amixer cset numid=3 <n>

where n is 0=auto, 1=headphones, 2=hdmi.

If you are running Debian, try

cd /opt/vc/src/hello_pi/hello_audio

make

./hello_audio.bin

to test analogue output. And

./hello_audio.bin 1

to test HDMI.

Also note that you may have to add your user to the 'audio' group to get permission to access the sound card.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: command line music making

Tue Jun 12, 2012 2:00 am

http://packages.debian.org/squeeze/chuck
and
http://packages.debian.org/squeeze/csound
both list armel packages, and http://packages.debian.org/wheezy/supercollider is only available in wheezy (unstable) rather than squeeze (stable) but it also lists an armel package.

timr
Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: command line music making

Tue Jun 12, 2012 2:30 pm

My Pi arrived this morning. I installed the debian6-19-04-2012 image.
chuck installed easily:

Code: Select all

sudo apt-get update
sudo apt-get install chuck
but since I already had it running in qemu, I expected that.

On-board sound

I used the snd_bcm2835 module, and alsa_utils as described

The audio quality from aplay (the Front_Center.wav test) is ok, apart from the first 0.1s (est) of the sample, which is very poor. The HDMI and headphone outputs are similar.

The audio quality from chuck is not usable, from HDMI or headphone output. This is using the examples in /usr/share/doc/chuck/examples/stk

On starting chuck, CPU usage goes up to around 100%, then after a few seconds, it hangs and CPU use then drops back to normal. It can be interrupted with Ctrl-C

USB audio

I have some usb headphones I use for Skype. They were recognised by the kernel with no work required. I created /etc/modprobe.d/sound with the line

Code: Select all

options snd-usb-audio index=0
to make them the default output.

The audio from aplay is now fine.

The audio from chuck is not. It doesn't hang any more, and the sound is recognisable, but it's not great. The cpu load is still pegged at 100% while generating audio. Maybe I can change the sample rate so that less work is required to create the waveform, but I suspect that may not be sufficient when generating more complex (polyphonic) sound.

Another avenue will be to enable hard-float, but that will probably be a bit more work, and I would like to see if I can profile the system first.

Thanks
tim

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: command line music making

Tue Jun 12, 2012 3:12 pm

Does chuck have a "record to WAV" type option? If so maybe you could time how much slower-than-realtime it is?
timr wrote:Another avenue will be to enable hard-float, but that will probably be a bit more work, and I would like to see if I can profile the system first.
Shouldn't be too hard, using Raspbian? http://www.raspbian.com

rvalles
Posts: 25
Joined: Tue Jun 12, 2012 3:51 pm

Re: command line music making

Tue Jun 12, 2012 10:01 pm

If GUI is also fine, raspbian (probably debian too) has milkytracker, and it works well.

Just don't make the window too big. Due to the lack of 2d accel the CPU has to draw the scrolling patterns as modules play, and with big windows it can't keep up and the ui stops responding.

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Tue Jun 12, 2012 10:26 pm

AndrewS wrote:http://packages.debian.org/squeeze/chuck
and
http://packages.debian.org/squeeze/csound
both list armel packages, and http://packages.debian.org/wheezy/supercollider is only available in wheezy (unstable) rather than squeeze (stable) but it also lists an armel package.
that was indeed lazy of me ;) thanks for doing the leg work, can probably backport or pin down supercollider, or build a wheezy for the raspberry pi!

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Tue Jun 12, 2012 10:42 pm

timr wrote: The audio quality from chuck is not usable, from HDMI or headphone output. This is using the examples in /usr/share/doc/chuck/examples/stk
sad to hear that I wouldn't have though that chuck would be so much cpu hungry... hopefully there is a way to overcome that limitation. I don't think supercollider would be less cpu hungry... it might leave csound as the only contender for coding music (that is not live coding either)...

I'll do some testing on my side and report what I can get out of this.
edit:
For the hard float HexxehImages seems to be doing the trick : http://www.raspbian.com/HexxehImages

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Wed Jun 13, 2012 4:45 am

http://www.linuxsystems.it/2012/06/rasp ... mal-image/

this is a minimal wheezy version (supercollider ;) with the hardware floating point... should be faster too since it's a minimal install to start with. Writing the image to sd card now, will give some test with chuck too later tonite ;)

timr
Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: command line music making

Wed Jun 13, 2012 10:54 am

I grabbed the image from http://raspbian.com/HexxehImages and tried the same process. I was expecting problems (packages not available, whatever) but it ws just as easy as the standard image.

The audio is good (I'm using my USB headphones, I'm not going to worry about the on-board audio for now), CPU usage is now much more reasonable:

Code: Select all

wurley.ck    50%
mandolin.ck  40%
rhodey.ck    65%
As a very approximate figure, the CPU usage is about 10x what my Core2 laptop shows for the same chuck patch.

This looks promising, now I need to create a more representative test, and to see how usage scales with more polyphony.

Thanks

tim

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Wed Jun 13, 2012 5:32 pm

yay - just playing with chuck right now and it seems responsive, although the sound from the headphone directly in the pi. I am using http://www.linuxsystems.it/2012/06/rasp ... mal-image/ and it was quite easy to setup everything...

I am tempted to tryout some sc action now ;) this is getting better -

please keep us updated of the code that you try around - I am only working with the simple examples provided on chuck site

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Wed Jun 13, 2012 6:46 pm

chuck is working well with basic coding, it seems to crash the alsa audio when too many layers are added.

Are you using alsa and or jack and or oss ?

timr
Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: command line music making

Thu Jun 14, 2012 8:43 am

I haven't tried anything more than the simple examples yet, and my final application will only require fairly simple patches. It will just be a limited number of oscillators triggered by OSC events, no filters or anything.

I'm using alsa at present: I'm not very knowlegable on linux audio, so I don't know the pros/cons of alsa vs. other options.

In any case, I would think the behaviour of alsa would be independent of what chuck is doing (assuming no resource issues) because I would expect chuck to do its own mixing down to one stereo signal, regardless of how complex the patch is. I could be wrong, of course. And maybe I mis-understand what you mean by 'layers': Is this polyphony?

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Sat Jun 16, 2012 6:19 pm

I meant if I chuck + simple to many time from the command line.

It's alsa that is crashing after few test. When I start alsa again, I can hear a bit of music from chuck and the alsa crash again. Since alsa is in 'alpha' development on that platform, I'll start to search about oss and see if that would be more stable. I am not sure how to use jack from the command line, and if it would actually be useful as it would probably use alsa in the back end anyway

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: command line music making

Mon Jun 18, 2012 2:30 am

AIUI it's the low-level-driver itself that is in Alpha, so OSS (if it works) would probably have the same/similar problems as ALSA? So I guess if you want properly-working sound "now", your best option would be a USB soundcard?

User avatar
damaru
Posts: 39
Joined: Fri May 11, 2012 2:11 am
Location: Canada
Contact: Website

Re: command line music making

Tue Jun 19, 2012 7:14 pm

AndrewS wrote:your best option would be a USB soundcard?
yes at this point sound card seem the only way out.

I couldn't find any information on the development of the alpha audio driver, wondering about timeline and where it is at.

timr
Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: command line music making

Fri Jun 29, 2012 4:27 pm

Update, in case anyone's interested

I have given up on chuck, at least in the way I was using it before. Instead, I have some C code which will read note events and play pre-created samples through alsa.

That seems ok, though there are some audio artifacts on the Pi which do not occur on my laptop.
CPU usage when generating four-note polyphony is around 6%

So now I have code which turns a score into a series of note-on and note-off events, and assigns the notes to sound generating channels. Previously I had this emitting OSC events to chuck, but I think it will be easier now to combine the various bits into a single executable.

The next step will be to generate some samples to replace the sinewaves I currently have. I thought I might use chuck for that, since I don't have access to samples from real instruments.

I'll probably make the code which reads the samples out more sophisticated, and give the sound some decay, instead of just turning it off with a note-off event.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: command line music making

Tue Jul 03, 2012 4:32 pm

Apologies if this is a stupid question (I don't have any music/sound experience, so I suspect it is! :oops: ) but isn't that the same sort of thing that MIDI does?

timr
Posts: 22
Joined: Wed May 30, 2012 10:11 am

Re: command line music making

Sat Jul 07, 2012 6:16 pm

No, it's not a stupid question.
I tried some synthesiser packages, but didn't have much luck. Also, many of them seemed to require X, and I don't want that.
I was also concerned about whether the CPU is powerful enough to handle it (for chuck, it's not) so I wanted a solution with the lowest possible amount of CPU. I thought that if I pre-calculate all of the samples, and have a sample per note, then there is no maths required apart from summing the outputs of each note generator. That seems to work, so that sound generation typically uses about 10% CPU.

Since then, I tried fluidsynth and found that it works ok on the raspbian (hard float) image, but it doesn't run properly on the debian one (exits with the message 'killed') and although the CPU usage is higher than with my implementation, it seems tolerable at about 35%. And, the sounds are better than I have.

So maybe I could use fluidsynth, with events sent from my own script. Either way, I got some excuse to learn about alsa...

tim

the_mink
Posts: 1
Joined: Mon Jul 16, 2012 12:51 am
Location: San Francisco

Re: command line music making

Mon Jul 16, 2012 1:34 am

So from this thread so far, it sounds like it'd probably be possible to write a simulated analog ADSR synth in C, as long as it's not too complex? (And with hard float support, assuming it was written with floating point math, which would be easier.) But using chuck would take too much CPU?

timr, where are you getting the OSC events from? I'm wondering if I could get MIDI events from a USB hardware device.

I'm an experienced programmer but new to Raspberry Pi (don't have one yet), and I'm wondering what I could do with one. I was thinking music, and this was the first thread I found.

dausua
Posts: 6
Joined: Sun Sep 23, 2012 5:44 am

Re: command line music making

Fri Oct 26, 2012 3:33 am

Hi, just thought I would share my experiences with Csound, since I've had many problems.

I narrowed all my woes (finally) to the onboard audio interface. The pi works smoothly with a USB audio interface, but drops samples and generally fails on the onboard. I know this has been pointed out elsewhere.

I have had Csound running very smoothly playing scores and doing realtime audio. It was as easy as

Code: Select all

sudo apt-get update
sudo apt-get install csound
and then alter the Csound audio interface to be the USB audio one, by selecting the number related to your interface. All USB ones seem to come up as 1, so set -dac1 or -odac1.

Code: Select all

-odac1 -+rtmidi=PortMIDI -M1 -r44100 -k441

pukulsesuatu
Posts: 5
Joined: Fri May 10, 2013 5:03 pm

Re: command line music making

Thu Jun 06, 2013 6:09 am

Hi all, I have problem with chuck when using usb soundcard but chuck run normally when I using onboard soundcard.
this is output when I using soundcard external

Code: Select all

[chuck]: RtApiAlsa::getDeviceInfo: pcm device (hw:0,0) data format not supported by RtAudio.
[chuck]: RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (hw:0,0), Device or resource busy.
[chuck]: RtApiAlsa::getDeviceInfo: pcm device (hw:0,0) data format not supported by RtAudio.
[chuck]: RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (hw:0,0), Device or resource busy.
[chuck]: RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (hw:0,0), Device or resource busy.
[chuck]: RtApiAlsa::probeDeviceOpen: pcm device (hw:0,0) won't open for output.
[chuck]: cannot initialize audio device (use --silent/-s for non-realtime)

somebody know how to fix it?
thanks

Return to “Advanced users”

Who is online

Users browsing this forum: ipph and 25 guests