sdaau | 30 May 06:41 2011
Picon
Picon

AudioArduino - an ALSA soundcard driver for FTDI-based Arduinos

Hi all,

(cross-posting to alsa-devel@... and 
gmane.linux.usb.general/linux-usb@...; apologies if it's 
inappropriate)

I'd just like to inform that the AudioArduino project has been posted 
online:

http://imi.aau.dk/~sd/phd/index.php?title=AudioArduino

It contains links to open-source Arduino microcontroller code, and 
corresponding ALSA driver source code - which can demonstrate mono, 
full-duplex, 8-bit / 44.1 kHz soundcard operation on an FTDI-based Arduino.

There is also a related post on the (new) Arduino Forum:
http://arduino.cc/forum/index.php/topic,62582.0.html

The driver essentially represents an ALSA extension to ftdi-sio (which 
is why I thought it would be relevant to both alsa-devel, and 
linux-usb). Many thanks to the community for critical help, like in:

ftdi_sio, and usb_serial->interface->dev->driver_data being null
http://comments.gmane.org/gmane.linux.usb.general/30455

Help with dummy.c (where/how to write?)
http://comments.gmane.org/gmane.linux.alsa.devel/74487

Looking forward to any feedback regarding this project,

(Continue reading)

Greg KH | 30 May 09:42 2011

Re: AudioArduino - an ALSA soundcard driver for FTDI-based Arduinos

On Mon, May 30, 2011 at 06:41:08AM +0200, sdaau wrote:
> Hi all,
> 
> (cross-posting to alsa-devel@... and
> gmane.linux.usb.general/linux-usb@...; apologies if it's
> inappropriate)
> 
> 
> I'd just like to inform that the AudioArduino project has been
> posted online:
> 
> http://imi.aau.dk/~sd/phd/index.php?title=AudioArduino
> 
> It contains links to open-source Arduino microcontroller code, and
> corresponding ALSA driver source code - which can demonstrate mono,
> full-duplex, 8-bit / 44.1 kHz soundcard operation on an FTDI-based
> Arduino.
> 
> There is also a related post on the (new) Arduino Forum:
> http://arduino.cc/forum/index.php/topic,62582.0.html

Very cool stuff, nice job!

Any thoughts about submitting back your kernel driver changes so we can
add them to the main kernel tree so that people don't have to build
out-of-tree kernel drivers to use this?

It could just be an option to the existing ftdi_sio driver that is
enabled somehow for a specific device, right?

(Continue reading)

sdaau | 30 May 17:28 2011
Picon
Picon

Re: AudioArduino - an ALSA soundcard driver for FTDI-based Arduinos

Hi Greg K-H,

> Very cool stuff, nice job!
>
> Any thoughts about submitting back your kernel driver changes so we can
> add them to the main kernel tree so that people don't have to build
> out-of-tree kernel drivers to use this?
>

Thanks for the encouraging and kind feedback - and of course, for all 
your (and everyone else's) work, that forms the backbone of the project!

I would, personally, be very happy to have a contribution in the kernel 
:) One reservation that I'd have, is that often times I read on mailing 
lists that the kernel is 'bloated'. And since this is a driver for a 
device not (necessarily) intended to be a soundcard - essentially, a 
(basic) academic exercise in providing an example of a working, yet 
fully open soundcard, spanning both software and hardware -  I'm fearing 
that some users may consider it a 'bloat'; but maybe that is irrelevant?

However, the bigger concern for me is how one would do it technically:

> It could just be an option to the existing ftdi_sio driver that is
> enabled somehow for a specific device, right?
>

Well, I wish it was so - but unfortunately, it is not that way currently.

The thing is, I'm not really an expert in programming, and even less in 
kernel drivers. So, for the time that I had at my disposal, the only 
(Continue reading)

Greg KH | 3 Jun 07:37 2011

Re: AudioArduino - an ALSA soundcard driver for FTDI-based Arduinos

On Mon, May 30, 2011 at 05:28:52PM +0200, sdaau wrote:
> >It could just be an option to the existing ftdi_sio driver that is
> >enabled somehow for a specific device, right?
> >
> 
> Well, I wish it was so - but unfortunately, it is not that way currently.
> 
> The thing is, I'm not really an expert in programming, and even less
> in kernel drivers. So, for the time that I had at my disposal, the
> only thing I could have done is try to understand ALSA driver
> architecture a bit better - while the USB part is completely
> "abstracted".
> 
> What I mean by that, is that the main driver file
> (ftdi_sio-audard.c) is first and foremost a copy of ftdi_sio.c from
> 2.6.32 kernel; then it includes a 'snd_ftdi_audard.h' file, which is
> here not a traditional header; it simply contains additional
> functions which 'add' the ALSA interface to ftdi_sio.c.
> 
> Finally, the two architectures are connected, such that the ftdi's
> callbacks also call the ALSA related callbacks, in particular:
> 
> * ftdi_sio's ftdi_process_packet (raised on incoming USB data) calls
> ALSA-related audard_xfer_buf function (and so the audio capture
> direction is handled)
> * ALSA related snd_card_audard_pcm_timer_function calls ftdi_sio's
> ftdi_write function (which controls outgoing USB data - and so the
> audio playback direction is handled).
> 
> I've just posted a diff on the SVN repository between the current
(Continue reading)

sdaau | 3 Jun 20:22 2011
Picon
Picon

Re: AudioArduino - an ALSA soundcard driver for FTDI-based Arduinos

Hi all,

Missed a couple of replies, so I'll try to answer everything now... We 
may be going slightly off topic as far as both linux-usb and alsa-devel 
are concerned - I hope the respective communities won't mind :)

On 2011-05-30 23:15, Sid Boyce wrote:
>>
>> Thanks, just wondered. With many SDR (Software Define Radio) project we
>> are constantly on the lookout for higher performance cards that are not
>> bandwidth restricted.
>>
>> There are many interesting projects out there using arduino, good luck.
>> I've got a Teensy++ 2.0 on the way to have a play with.
>> Regards
>> Sid.
>>

Hah - I noticed the signature, but I didn't really see the connection, 
until you clarified about SDR! :) Thanks for the note, and the reference 
to Teensy (have been hearing about that lately, but haven't had the time 
to look deeper)...

On 2011-06-03 07:37, Greg KH wrote:
> [snip]
>>
>> I've just posted a diff on the SVN repository between the current
>> ftdi_sio-audard.c and the original ftdi_sio.c from kernel 2.6.32:
>>
>> http://sdaaubckp.svn.sourceforge.net/viewvc/sdaaubckp/audard/snd_ftdi_audard-an8m/sio2.6.32-audard.diff?revision=211&view=markup
(Continue reading)

Caleb Crome | 4 Jun 02:34 2011

Re: AudioArduino - an ALSA soundcard driver for FTDI-based Arduinos

On Fri, Jun 3, 2011 at 11:22 AM, sdaau <sd <at> imi.aau.dk> wrote:

> On 2011-05-30 23:51, Caleb Crome wrote:
>
>> FYI, if you can raise the PWM rate on the arduino output, you can use
>>> modulation tricks to increase the resolution.
>>>
>>
> On the Arduino Duemillanove , there is 16 MHz clock and ATmega328 - as far
> as I could gather, the highest possible PWM frequency there is 62.5 kHz (in
> Fast PWM mode - achievable by setting the correct prescalers).

Ah, so that's not going to let you get too far in terms of oversampling.
 You could set your audio bandwidth to 62.5 / 2 / 2 ~= 15kHz and try for
~9-bit resolution.  Here's the basic procedure:

On your host, resample the audio file to 62.5 kHz, lowpass filter it, and
convert it to 8-bits.  You can do this all as preprocessing steps until you
get it into your application.  It looks something like this:
> sox input.wav -r 31250 i1.wav      # This resamples to 31250 Hz.  This
includes a built-in antialiasing filter, so will limit bandwidth to
somewhere below 15kHz
> sox i1.wav -r 62500    i2.wav      # This resamples to 62500 Hz.  It
creates samples between all the 31250Hz samples that are interpolated.  This
is the important bit!
> sox i2.wav --bits 8 i3.wav          # This converts   to 8-bit samples.
(these sox command not tested ;-)

Now, you have a band-limited signal, with 8-bit samples.  However, the
sample rate is double what it would need to be for the limited bandwidth
(Continue reading)


Gmane