Shop OBEX P1 Docs P2 Docs Learn Events
Feasibility of Project with P2 and Audio Breakout Board for P2? - Audio Looper with 8 Tracks. — Parallax Forums

Feasibility of Project with P2 and Audio Breakout Board for P2? - Audio Looper with 8 Tracks.

Christof Eb.Christof Eb. Posts: 1,197
edited 2022-01-20 19:51 in Propeller 2

Hi all,
at the moment I am checking the feasibility of a new project and if this could be done with P2 conveniently.

I would like to build an audio looper, which shall have 8 mono tracks and a song length of up to 5 Minutes.
I want to store 32bits per sample.
As storage an SD-card shall be used.
To deal with wear of the SD-card, the data shall have parity (hence 32bits per sample).
Each file shall hold all 8 tracks in parallel.
Only one track (or 2 tracks for stereo) is recorded at a time, all other tracks are just copied.
Mixer only for output of all tracks with stereo panning.
No overdubbing
Data shall be written in parallel to two redundant files.
Data shall be read in parallel from the two redundant files to be able to discard bad data.

Storage for Song:
32bit, 8Tracks, 5 Minutes
4 * 8 * 5 * 60 * 44100/1024/1024=403,7476 Megabytes

Bandwidth 2 files read, 2 files written in parallel
4 Files, 32bit, 8 Tracks
4 * 4 * 44100=705600*8 Bytes/sec

Circular Buffers in Ram.
Additionally the start of the song shall be kept in Ram to be able to go to the start of the record quickly.

Minimal latency!
Display ILI Touch screen
4 foot switches, rotary encoder
? Use of Tachyon Forth ?

One direction of question is about the needed bandwidth of the SD-card. I know, that SD-cards do need some time sometimes.
Is the average bandwidth of about 1Megabyte/sec possible?
What size of the RAM buffers is needed?
Is this possible with a file system or will it need some raw access to the SD-card?

The other questions with P2 are about audio ADC/DAC
I there a 24-bit ADC/DAC breakout board, which can be used with P2? (Or 16bits?)
Is there a I2S driver for it?
Any other comments?

Many thanks in advance!
Christof

Comments

  • of course it is possible, but you will have to make it happen. A lot of SPIN2 programming involved.

    Quick search for ,,audio adc evaluation board"

    1. result. 4 high quality inputs (even differential)
      https://www.ti.com/tool/PCM1840EVM#tech-docs
      Seems easy to interface on the first glance

    get a separate DAC or ,,audio codec"
    browse to analog or TI and check out their chips, get a evalboard for that

  • evanhevanh Posts: 15,915
    edited 2022-01-20 11:45

    Bandwidth is easy enough. Plenty to spare. And can have extra RAM chips for extensive buffering in case of SD stutters.

    Earlier reports are that the Prop2's 8-bit DACs are pretty good for audio. Far better than you'd think because they're fast and highly precise (Non-linearity is around 14-bit effective) and can be easily dithered and oversampled.

    Pik has done some work in this area - https://forums.parallax.com/discussion/174214/paula-amiga-inspired-audio-driver
    Ahle also has done a collection but this is likely the one - https://forums.parallax.com/discussion/172894/simplesound-a-simple-to-use-sound-engine-for-the-p2/p1

  • Hi Christof,

    I have an I2S driver for a PCM1807. It's probably not of much help because it's only ADC input and I use it to read angular position from a resolver, not for audio. But it's a good example of how to use the smart pins for I2S communication so you don't have to start from scratch.

  • Hi, thank you everybody!

    @Simonius said:
    of course it is possible, but you will have to make it happen. A lot of SPIN2 programming involved.

    Quick search for ,,audio adc evaluation board"

    1. result. 4 high quality inputs (even differential)
      https://www.ti.com/tool/PCM1840EVM#tech-docs
      Seems easy to interface on the first glance

    get a separate DAC or ,,audio codec"
    browse to analog or TI and check out their chips, get a evalboard for that

    Funny, no, I don't feel ready to pay 170Euros....
    There are plenty of cheap DAC boards but Audio ADC+DAC with Line in for a reasonable price seem to be rare....

  • pik33pik33 Posts: 2,366
    edited 2022-01-20 16:01

    You don't need i2s DACs, P2 DACs are one of the best I have ever tried. You only need an analog buffer/mixer/preamp to connect to these DACs before you connect these outputs to headphones/amplifier.

    You can check my "Paula-like" thing to see how to output audio samples. You will need slightly different aproach there: use PWM DACs at 1/256 of the man clock. You can get way over 100 dB dynamic range out of these DACs in this mode (16-bit, ~1.25 MHz )

    There is no purpose to add parity to SD based samples. Either the block is good, and the parity is not needed, or is bad and all you can do is throw the SD away. One bad block equals a bad SD card.

    The rest can be easily done if you learn how to use a filesystem on SD (I am learning this now) and if the SD driver is fast enough. The samples have to be cached and prebuffered in RAM, SD can give several miliseconds of delay: these pauses can be, and are, hearable, I tested this in other environments.

    You may consider using PSRAMs (the new Edge module) or Hyperram board for additional fast memory for samples.

  • @"Christof Eb." said:
    Hi, thank you everybody!

    Funny, no, I don't feel ready to pay 170Euros....

    I guess you pay for the high fidelity. And you would have a fully documented board which will save you time.

    Why don't you use the ADCs and DACs the propeller has built in? You can upgrade later

    Is this a hobbyist/ or a commercial project?
    how many should be built?

  • @pik33 said:
    There is no purpose to add parity to SD based samples. Either the block is good, and the parity is not needed, or is bad and all you can do is throw the SD away. One bad block equals a bad SD card.

    Yes and no.
    Yes the SD card does its own internal error correction (as is needed for multi-level flash), so yeah there's zero need to check integrity yourself, especially with something like uncompressed audio, where a single flipped bit is barely perceptible. The SD card also rewrites blocks that'd be affected by read-disturb effects.
    No, blocks only go bad from writing and until a certain threshold isn't exceeded, it will happily work around any bad blocks (as there will be a bunch from the factory already). If there's too many, most cards will change into a read-only mode.

  • @pik33 said:
    The rest can be easily done if you learn how to use a filesystem on SD (I am learning this now) and if the SD driver is fast enough. The samples have to be cached and prebuffered in RAM, SD can give several miliseconds of delay: these pauses can be, and are, hearable, I tested this in other environments.

    I've looked into SD delay and you can totally get sub-millisecond delay for reads:
    - Use a card that's actually good (see: A1 rating). That 1GB fard you pull out of a 10 year old digicam won't do.
    - NEVER de-assert chip select. The SanDisk cards I use, if you leave CS high for about 10ms, they go to sleep and take a while to wake up again.

    I haven't measured exactly, but 400us (including actual transfer) for a single block read are realistic.

  • pik33pik33 Posts: 2,366
    edited 2022-01-20 18:52

    The practice can differ from theory. One of my cards could give a second, or something like this, delay, in random moments, but while sequential read. Yes, I tried it in a WAV player and I don't use it anymore, for anything. Something cheap and chinese from a local hypermarket.

    I hope a good (Samsung, Sandisk) cards, A1 or A2 should be better, of course.

    But then one of my Sandisk A1, 32 GB cards became a Sandisk A1, 32 MB card without any warning. All data went to make love. All tools I tried on it saw a 100% good SD card, but 32 MB instead of 32 GB.

  • Christof Eb.Christof Eb. Posts: 1,197
    edited 2022-01-20 19:52

    OK, I have now learned, that SD cards have very varying write times and worst times are very much slower than average. Comes from erasing, as far as have understood.
    The internal controller of the card will ensure error handling due to wear.

  • pik33pik33 Posts: 2,366
    edited 2022-01-20 20:37

    The internal controller of the card will ensure error handling due to wear.

    If the card is modern and the manufacturer is well known and the file system is what the SD Association recommends for the card, then yes.

    elseif the card is vintage then no (older cards had no wear leveling system)
    else maybe, probably no.

  • evanhevanh Posts: 15,915
    edited 2022-01-21 04:42

    I would hope wear-levelling is block based with no awareness of a filesystem being present. After all, if the boot-block needs swapped out then that's outside of the filesystem, even outside the filesystem meta-data areas.

  • Seems like everyone and their dog is using a looper today. To me, it's like Chinese torture and I can only stand so much.

    Question: Many performers appear to have difficulty with synchronisation. Don't all modern loopers have auto-quantization? My Digitech GNX4 has this feature and it's from 2005.

Sign In or Register to comment.