electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Developers' Corner
RaspberryPi 2 B
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 3 [53 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: 1, 2, 3 Next
Author Message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Fri Nov 27, 2015 8:03 am    Post subject: RaspberryPi 2 B Reply with quote  Mark this post and the followings unread

I've just ordered (soon to receive) a RaspberryPi 2 B. I will be getting the basic "kit" which has the wifi adapter, HDMI cable, PSU, box and some other stuff. I've also ordered a Cirrus codec board for it to provide 24 bit up to 192 kHz stereo audio in and out.

The CPU is an ARM cortex-a7 4 core running at 900 MHz. What I've read about it indicates that under the right conditions it can be overclocked. I'm pretty sure that's enough horsepower to run a synth with FX.

This board was (I believe) released about 3 years ago. wmonk point it out to me a few days ago.

The pi forums show projects or bits of projects that include musical use, so I hope to find things like audio board drivers and MIDI connections to the board.

Anybody else playing with this?

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
sonic



Joined: Dec 02, 2010
Posts: 106
Location: Victoria BC

PostPosted: Sat Nov 28, 2015 10:50 am    Post subject: Reply with quote  Mark this post and the followings unread

I'll be getting one of these too I reckon. I fancy the new $5 Pi Zero too. Only thing is the zeros don't seem to be available in Canada yet, and no ethernet port...

In the short term I am investigating connecting to midi ports via C on linux. No need to get the pi yet to figure this bit out at least.
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sun Nov 29, 2015 8:30 am    Post subject: Reply with quote  Mark this post and the followings unread

Cool man! Oh, I love your avatar...

I looked at the Pi zero too, but first - I can't find it for $5 and the lack of ethernet is a killer for me. I may get the Pi 1 to do a TV record/playback thing, however, I may simply order another Pi 2 for that since in the end the price/performance ratio is much better with the 2 and it's not really that expensive.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
jksuperstar



Joined: Aug 20, 2004
Posts: 2503
Location: Denver
Audio files: 1
G2 patch files: 18

PostPosted: Sun Nov 29, 2015 9:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

I had both Pi 1 and 2B, the 2 is way faster/smoother than the first one. I tuned Linux on the first, but the lowest latency I could see was about 20ms...nothing great. Might be better for baremetal, or simple sketches that arduino can't handle instead of full Linux, but I'm think real-time. The pi2b is more graceful in its format, implementation and speed.
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sun Nov 29, 2015 10:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

baremetal as in RTOS? I'm definitely looking at RTOS. I'd like to run Linux in one core and see what I can do with RTOS in the other three. Linux would control it (well, that's my hope/desire).
_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
jksuperstar



Joined: Aug 20, 2004
Posts: 2503
Location: Denver
Audio files: 1
G2 patch files: 18

PostPosted: Mon Nov 30, 2015 11:36 am    Post subject: Reply with quote  Mark this post and the followings unread

FreeRTOS might be a good option. I was thinking no-OS (aka while-loop/IRQ).

For the Pi1, I even disabled X-windows, and still didn't get much gain. Could be drivers/peripherals, could be bad DDR tuning, or something else was making the response time slow. I didn't recreate the effort for the Pi2...but it is much faster simply running linux with X, or as a game emulator which I ultimately used it for Smile .

(I got both boards as part of a work related hack-a-thon, so I wasn't seeking either of these out)
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Mon Nov 30, 2015 2:38 pm    Post subject: Reply with quote  Mark this post and the followings unread

Ah, ok, no OS at all and a while loop with IRQ ISRs, that's what I've done with dsPICs in assembly and a couple of times in C. For a headless music machine, that ought to be quite capable.

At this point, however, I have no idea how to get there from here in the pi world - any reading URLs or righteous google searches? Smile

I can do that, but I'd like to see what I can do with freeRTOS since it's been "successfully ported" to the Pi2 environment. I'll need to do the deep reading on that. There seems to be some web reading material regarding low latency audio on Rpi, I assume Rpi2 being better.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sun Dec 06, 2015 10:45 am    Post subject: Reply with quote  Mark this post and the followings unread

wmonk kindly helped me get ArchLinux running with a desktop while we were in chat. I captured the chat log, edited out non essential text, added comments and file contents and produced what I hope will help others who want to use something which I think is more robust and better than raspbian linux.

See it at: ArchLinux Installation Notes

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Dec 12, 2015 5:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

I've now got the Cirrus/Element14 audio board plugged in and working with raspbian Linux. The sound quality is quite good from wav or flac, the usual with mp3.

I'm still working on getting Arch Linux to use the board.

I also need to try recording.

Using mplayer to play an mp3 file causes virtually no increase in CPU use.

I've used both VLC and mplayer to connect to the electro-music site's radio channels.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sun Dec 13, 2015 4:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

Many LARGE thank-yous to wmonk for helping me out with Arch Linux and the Cirrus/Element14 sound card.

He pointed me to headless.audio.

I followed their instructions and it works like a charm.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Tue Dec 15, 2015 1:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

There appear to be several ( 8 that I found ) MIDI synthesizer programs written for Linux that are supported with packages for Arch Linux on Raspberry Pi. I have not looked into raspbian Linux for this as I prefer Arch. I will be testing these programs out to see what capabilities they have running on a CPU like the Rpi2 has. Obviously, I don't expect 32 voice polyphony, but it would be nice to see things like this run without problems. Many of the synths have published source code, so it should be possible to examine that for clues to write my own. If these work, it will be an encouragement to move forward with learning freeRTOS and bare metal techniques to get more out of the ARM.
_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Thu Dec 17, 2015 11:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

Today with much hacking (and swearing) I got ZynAddSubFX running and I got my MidiSport 2x2 working with it (Arch Linux) using the Cirrus/Element14 audio sound board as output. It would seem that even under Linux, this CPU is quite powerful enough to do polysynth stuff. I have no measurement of latency, but it didn't seem noticeable to me, however I played only with simple presets. Memory use was around 36% (total) to have the synth loaded.

Getting the MidiSport 2x2 to work was the larger issue, the program that pushes the firmware into the midisport 2x2 had to be compiled - and because the code is old and moldy, that wasn't straightforward; I had to make changes to some of the compile files and the installer.

I'm impressed with the Raspberry Pi 2, quite capable. I have a feeling it can be awesome with RTOS or bare metal.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Fri Dec 18, 2015 9:01 am    Post subject: Reply with quote  Mark this post and the followings unread

For others trying this, here are some things I did to make this all work.

First, I'm using command line options to use ALSA to connect MIDI to the ZynAddSubFX and connect pulse audio for output. I'm using a script to do this, so it's a bit tricky.

The synthesizer is started with:
Code:
zynaddsubfx -I alsa -O pa -a

Note that -O references pa (pulse audio) which refers to the audio board. I was getting an annoying error pop-up until added '-O pa'.

The script uses
Code:
aconnect -lio

to interrogate which devices ALSA can see what devices are available for connecting. The MIDIsport shows up right away and the ZynAddSubFX synth shows up once it's initialized. Once the synth is discovered by the script, it issues an aconnect command with the device numbers found by aconnect -lio. This process allows me to type one script name which launches both Zyn and the watcher script, connections to audio and MIDI are made automatically and the synth is ready to play.

I'm looking at ways to improve this startup, I believe that there is a way to invoke an after-initialization script from Zyn which could be used to make the MIDI connection to the MIDIsport 2x2.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Fri Jan 08, 2016 6:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

With the help of a nice person (StuartF) on the Raspberry Pi forum, I was able to use the console UART for MIDI by changing it's baud rate to 31250 and using a program called "ttymidi" to create an ALSA connector from that console UART port. This allows MIDI input to the Raspberry Pi without a USB device which should be helpful also for bare metal programming.

I've played with the ZynAddSubFX soft synth to see both it's strengths and it's flaws. It appears to support 10 voices of polyphony. Some of the voices sound pretty nice. The FX are pretty good too. It's not perfect for sure, like any soft synth it can be pushed too far. But it does demonstrate the power of the ARMv7 IC. During operation, it seemed not to tax the CPU much with one core usage at about 60% max. Memory use climbed to something less than 1/2 total RAM. I take this to show that with a bare metal approach, the chip should be quite capable of well more than 10 voices of complex synthesis with audio effects. I'm quite impressed with the power of the system.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Jan 30, 2016 2:52 pm    Post subject: Reply with quote  Mark this post and the followings unread

I've been making good headway with this.

Except for /boot, the whole file system for it is on a portable USB hard drive, so no more heavy wear and tear on the micro SD card.

I've been able to build a hardware MIDI connection (6N138 thing) which uses the Pi2 UART normally intended as a console TTY as a MIDI input. The challenge there was getting the UART to run at 31.25 kbaud. I built this to avoid yet another thing plugged into USB and having to share it's bus with other randomly firing devices.

I've also been able to generate a sinewave using arithmetic (instead of wavetable or sound file) to my sound device. This is a very rudimentary synth. It uses the asynchronous transfer method.

I'm currently working with threads and assigning specific cores to them including the use of isolated CPUs. This approach will isolate all of the mundane interrupt handling to one core for the linux kernel to handle without "bothering" the cores that will be running my synthesizer code.

I've written a simple MIDI controller pre-design that prints the message hex data as it arrives. The controller and printer functions are separate threads running on different cores. The threads communicate through shared memory.

Next is to write a simple MIDI synthesizer (just sine) using isolated cores and threads.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Feb 06, 2016 4:37 pm    Post subject: Reply with quote  Mark this post and the followings unread

Lots of progress up to today.

I now have a 32 voice MIDI organ-type sine synth. Very simple sin(a)+sin(2a) on/off eg with ramp up and ramp down and 32 voice polyphony. I have the sound generation code running as a thread on an isolated core. I will have to measure it, but it feels like any MIDI instrument I've played.

The core running the sound generation code idles at about 56% to 58% CPU and goes to 84% CPU or so when all voices are busy.

I use ALSA direct mmap writes in a polling loop. This allows launching the infinite loop as a thread on an isolated core and letting it use all of it. There is probably room to add more voices.

The instrument's buffering latency is quite low, I use settings that provide a period size of 8. At 44.1 kHz sample rate, that's worst case of 181.4 microseconds. I will have to measure time from receipt of full MIDI message to time of sound start. The MIDI controller runs in a different isolated core, but it shows zero CPU. If I twist as many knobs as I can to send tons of messages, it shows 1% usage on it's core.

This is with Arch Linux and LXDE desktop running in 2 cores... I want to see if headless makes a difference.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
ian-s



Joined: Apr 01, 2004
Posts: 2669
Location: Auckland, New Zealand
Audio files: 42
G2 patch files: 626

PostPosted: Sat Feb 06, 2016 11:26 pm    Post subject: Reply with quote  Mark this post and the followings unread

Nice, are you still using arithmetic sine waves?
Back to top
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sun Feb 07, 2016 5:32 am    Post subject: Reply with quote  Mark this post and the followings unread

Yeah, at this point this is still really in the "hello world" zone, and just calling the sine function is easier right now than a wave-table. I would guess that wave-tables are probably faster, not sure though considering the RAM is shared between all 4 cores. At this point, to get 32 voices with low latency is very encouraging. I've done very little optimization, so there's room for improvement in the code.

I'm currently working out how I might get another core doing a different synth so that it can be bi-timbral (maybe).

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Mon Feb 08, 2016 3:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

Here is a Handel piece 'Air and variations from "The Harmonious Blacksmith"' I found here that is playing to the Rpi2 running my organ synth program. There's no effect on it. The organ has 2 sine oscillators per voice, the second is a teeny bit flat of an octave above the first.


handel-airnvari.mp3
 Description:

Download
 Filename:  handel-airnvari.mp3
 Filesize:  3.68 MB
 Downloaded:  773 Time(s)


_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Tue Feb 09, 2016 6:09 am    Post subject: Reply with quote  Mark this post and the followings unread

Cool, you have liftoff!

The timing seems a bit odd here and there though?

It could be that the MIDI file was played in by a human tho ... in fact .. odd is not the right word, it's played nicely ... but hard to hear possible timing issues in the synth this way .. or maybe my brains are off .. that happens Laughing

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Tue Feb 09, 2016 6:27 am    Post subject: Reply with quote  Mark this post and the followings unread

I didn't modify the file at all. Other files on the site sounded hand played, so it's very possible this one was as well. Other files also had far worse/sloppier timing.

Anyway, this demo wasn't meant to say anything in particular about the synth other than that it makes sound. I'll be doing actual measurements of latency and other timing aspects after things are optimized.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Feb 13, 2016 8:54 am    Post subject: Reply with quote  Mark this post and the followings unread

Yesterday I got first sound from a 32 voice karplus-strong polysynth. Pitch bend (up to +/- 12 semitones) is supported. It has CC controls for the reflection filter and linear decay. It currently has looped delay as an effect with CC controls for delay time and feedback amount. I plan to try a reverb algorithm in it's place.

As I was developing ks32, I decided to increase the voice count until the synth either throws exceptions or starts having other problems. A setting of 64 was enough to cause audio stream exceptions. This meant to me that there is still a significant amount of computational power even with 32 voices running.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Feb 27, 2016 4:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

This is what the instrument can sound like currently.

Please enjoy this playing of Chopin's Fantaisie on my KS32 (Karplus-Strong 32 Voice) synth running on a Raspberry Pi 2B.


chopin_fantaisie.mp3
 Description:
Chopin's Fantaisie

Download
 Filename:  chopin_fantaisie.mp3
 Filesize:  4.19 MB
 Downloaded:  754 Time(s)


_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Sat Mar 12, 2016 5:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

Major breakthrough today.

I had measured the synth's latency defined as time from MIDI note-on receipt to time of first DAC activity. The latency was 24.5 milliseconds which I found to be quite bad. It was due to an overly large audio buffer. I was able to reduce the buffer size without causing problems for audio to allow a latency of 7 milliseconds worst case.

More new synths and effects will follow since I now have a framework for synth development.

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima

Last edited by JovianPyx on Sat Mar 12, 2016 7:49 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
sonic



Joined: Dec 02, 2010
Posts: 106
Location: Victoria BC

PostPosted: Sat Mar 12, 2016 7:29 pm    Post subject: Reply with quote  Mark this post and the followings unread

oh yeah! nice work Scott. So the testing was well worthwhile.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 3 [53 Posts]
View unread posts
View new posts in the last week
Goto page: 1, 2, 3 Next
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Developers' Corner
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use