Paul17041993
Posts: 3
Joined: Mon Jun 19, 2017 10:39 pm

Using the pi 3 as a 16+ channel DSP

Tue Jun 20, 2017 4:50 am

I'm basically looking for something that can handle at least 8 input and 8 output channels, 24bit at 96KHz, and so far I've found that the modern pi should be able to handle that easilly over GPIO, and possibly even a total of 32 channels, 32bit and 192K assuming the 25MHz max applies to all the pins?

The main problem I have with this idea atm is working out the hardware config, what would be the most suitable ADC and DAC chips and how should I connect them up? would I also need a I2S switch/break-out chip or would the 16 GPIO pins suffice? how good is the pi 3's internal clock for this or would I need a dedicated clock gen somewhere?

User avatar
mikronauts
Posts: 2722
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Using the pi 3 as a 16+ channel DSP

Tue Jun 20, 2017 5:32 pm

Good luck.

Odds of getting it working in any reasonable amount of time are very low.

Not impossible, but with that number of channels:

1) go bare metal
2) dedicate a core to inputs
3) dedicate another core to outputs

The issue is jitter free timing.

The 25MHz is not something guaranteed for all I/O pins simultaneously.

Two channels would be pretty easy as there is an I2S interface on-board.

You would be far better off to use four Pi Zeor's, each handling two channels.
Paul17041993 wrote:I'm basically looking for something that can handle at least 8 input and 8 output channels, 24bit at 96KHz, and so far I've found that the modern pi should be able to handle that easilly over GPIO, and possibly even a total of 32 channels, 32bit and 192K assuming the 25MHz max applies to all the pins?

The main problem I have with this idea atm is working out the hardware config, what would be the most suitable ADC and DAC chips and how should I connect them up? would I also need a I2S switch/break-out chip or would the 16 GPIO pins suffice? how good is the pi 3's internal clock for this or would I need a dedicated clock gen somewhere?
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Paul17041993
Posts: 3
Joined: Mon Jun 19, 2017 10:39 pm

Re: Using the pi 3 as a 16+ channel DSP

Tue Jun 20, 2017 9:40 pm

mikronauts wrote:Good luck.

Odds of getting it working in any reasonable amount of time are very low.

Not impossible, but with that number of channels:

1) go bare metal
2) dedicate a core to inputs
3) dedicate another core to outputs

The issue is jitter free timing.

The 25MHz is not something guaranteed for all I/O pins simultaneously.

Two channels would be pretty easy as there is an I2S interface on-board.

You would be far better off to use four Pi Zeor's, each handling two channels.
Paul17041993 wrote:I'm basically looking for something that can handle at least 8 input and 8 output channels, 24bit at 96KHz, and so far I've found that the modern pi should be able to handle that easilly over GPIO, and possibly even a total of 32 channels, 32bit and 192K assuming the 25MHz max applies to all the pins?

The main problem I have with this idea atm is working out the hardware config, what would be the most suitable ADC and DAC chips and how should I connect them up? would I also need a I2S switch/break-out chip or would the 16 GPIO pins suffice? how good is the pi 3's internal clock for this or would I need a dedicated clock gen somewhere?
I would definitely dedicate at least one core to IO and would use a custom driver, but wouldn't using multiple pi's further worsen the timing issue as I'd have to synchronise their buffers between them...?

I'll probably avoid the built-in I2S altogether though due to a lack of pins and clock/jitter issues I've heard about, which is where the clock question comes in because I have no idea how reliable the pi 3 is at generating 4,608KHz and 96KHz (data and L-R clocks)

User avatar
mikronauts
Posts: 2722
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Using the pi 3 as a 16+ channel DSP

Tue Jun 20, 2017 10:57 pm

My friend, I have been doing hard real time I/O for ~30 years, on a lot of different micro controllers.

It is a LOT more than a "custom driver". Frankly, I am not sure it is feasible at all, even at the lower clock rates.

Simultaneously bit-banging 16 channels of I2S audio (8 in, 8 out) in software on a Pi is a FAR reach, as the SOC is definitely not designed with this kind of application in mind.

I am not saying it is impossible, but it would be extremely hard, and would take a ridiculous amount of time, and at the end, not work satisfactorily.

Synchronising (to within a few us) four Pi's using GPIO and the hardware I2S channels is trivial by comparison.

Unless you have a lot of experience in writing cycle-accurate assembly language for ARM you are unlikely in the extreme to get it running. This is made more complicated on the Pi due to the caches and nature of the I/O bus.

Mind you, it would be a good learning exercise for you to find out why it won't run, and how tough something like this is.

Do post if you get it going, I would love to see it - and I'd be impressed.
Paul17041993 wrote: I would definitely dedicate at least one core to IO and would use a custom driver, but wouldn't using multiple pi's further worsen the timing issue as I'd have to synchronise their buffers between them...?

I'll probably avoid the built-in I2S altogether though due to a lack of pins and clock/jitter issues I've heard about, which is where the clock question comes in because I have no idea how reliable the pi 3 is at generating 4,608KHz and 96KHz (data and L-R clocks)
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

Paul17041993
Posts: 3
Joined: Mon Jun 19, 2017 10:39 pm

Re: Using the pi 3 as a 16+ channel DSP

Wed Jun 21, 2017 12:30 am

mikronauts wrote:My friend, I have been doing hard real time I/O for ~30 years, on a lot of different micro controllers.

It is a LOT more than a "custom driver". Frankly, I am not sure it is feasible at all, even at the lower clock rates.

Simultaneously bit-banging 16 channels of I2S audio (8 in, 8 out) in software on a Pi is a FAR reach, as the SOC is definitely not designed with this kind of application in mind.

I am not saying it is impossible, but it would be extremely hard, and would take a ridiculous amount of time, and at the end, not work satisfactorily.

Synchronising (to within a few us) four Pi's using GPIO and the hardware I2S channels is trivial by comparison.

Unless you have a lot of experience in writing cycle-accurate assembly language for ARM you are unlikely in the extreme to get it running. This is made more complicated on the Pi due to the caches and nature of the I/O bus.

Mind you, it would be a good learning exercise for you to find out why it won't run, and how tough something like this is.

Do post if you get it going, I would love to see it - and I'd be impressed.
The problem I see with using 4 pi's is that I'd have to cross-link them with the remaining GPIO pins to each other pi, which has limited scalability and might be even less possible to run reliably than a single pi with all the IO used, at that point I might as well just stick with dedicated DSP chips.

Though it may be possible to hit it half-way with a single pi and multiple DSP chips...

User avatar
mikronauts
Posts: 2722
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Using the pi 3 as a 16+ channel DSP

Wed Jun 21, 2017 4:47 pm

It depends on what you want to do with all those I2S channels.

I'd synchronise the Pi's with just one signal, possibly from a master, and transfer the data over Ethernet or USB, using a host to re-assemble/partition the channels - I would not even try to transfer the data between the Pi's over GPIO (basically same speed/complexity issue as I2S bit banging).

The idea of DSP's is attractive, but then begs the question - how will you get all that data to/from the DSP's fast enough?

Basically,

1) If this is a personal project, dive in. It will be a ton of work, frustrating at times, but you will learn a lot. You may not get it running.

2) If this is a commercial project, especially if it has less than a year or two to get done, put together a comprehensive specification of what it needs to do, and hire an experienced consultant to decide if it is feasible, and come up with some approaches. Do not try to dictate the tools to someone more experienced. Expect to pay a lot.

Frankly I run across similar issues often.

The price and popularity of the Pi make people want to use it for applications it was not designed for, even if there are better alternatives - and as they are not in the industry, they are not aware of alternatives.

I am NOT trying to discourage you - if this is a personal project, I actually encourage you to try, as I guarantee that you will learn a lot by trying.
Paul17041993 wrote: The problem I see with using 4 pi's is that I'd have to cross-link them with the remaining GPIO pins to each other pi, which has limited scalability and might be even less possible to run reliably than a single pi with all the IO used, at that point I might as well just stick with dedicated DSP chips.

Though it may be possible to hit it half-way with a single pi and multiple DSP chips...
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
flatmax
Posts: 336
Joined: Thu May 26, 2016 10:36 pm

Re: Using the pi 3 as a 16+ channel DSP

Thu Jun 22, 2017 12:32 pm

I have solve this problem over I2S, however it is limited to 8 out and in in my implementation - only 6 inputs are used.
I think it could go more, such as 16 channels @ 96 kHz ... hmmm ... would take a lot of work. A lot of management goes on in the FPGA on the hat... It tooks months to get right, non trivial :)

It can be done !

Another approach will be to use 8 Pis each running stereo channels in and out ... they can be ganged over one TDM I2S bus and only render I2S data in their time slot ... can your software be split over 8 Pis ?

Matt
Check the Ultra 2 sound card - use our shop instead of Amazon Europe (Amazon USA is live).
Sound card for the Raspberry Pi with inbuilt microphone : www.audioinjector.net
Audio Inector Octo multitrack GPIO sound card

Return to “Graphics, sound and multimedia”