SPDIF recorder

Discussion in 'Embedded Systems and Microcontrollers' started by aavikolla, Dec 6, 2010.

  1. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    Hi,

    I'm interested in making a digital audio recorder. The idea would be to record incoming SPDIF signal onto an SD card. The signal would be 24-bit resolution with 96kHz sampling rate. I don't have much experience with microcontrollers except for playing around with an arduino, so I was hoping I could get some advice from more experienced people.

    To work with I2S reliably, I expect the MCU has to have at least some level of hardware I2S support. On the other hand, writing to the SD card while receiving real-time data means that there has to be a substantial amount of memory available and a DMA controller would probably save me a lot of trouble.

    Can you guys point me towards good MCU candidates for a job like this? It would be especially great if there was a development platform which integrates the SD card reader, MCU and a programming interface. I fully expect that I need to integrate the high resolution SPDIF codec though.

    Thanks
     
  2. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
  3. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
  4. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    I own the EasyPIC6.

    Greatest things since pickled pigs feet.

    If you dont mind the expense (I think its a savings) get it.

    It will save you hours of wiring so you can get to code.
     
  5. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    I have no doubts that it's a great board and I fully realize that a ready-made multipurpose dev board will be a lot cheaper than any custom production for a one-off need. The question is really about physical size. A spdif recorder doesn't need that many components. I was wondering if there is a dev board with less features and as such which has a smaller footprint. Something more more towards the size of an arduino.
     
  6. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    I just found this "dev board".

    http://www.mikroe.com/eng/products/view/586/mikrommb-for-dspic33-board/

    Can you guys think of any reason why this wouldn't suit my needs? There's an mp3 decoder that's extra but i don't mind if it doesn't get in the way. The touchscreen is a nice bonus.

    One thing which bothers me a bit is that mikroelektronika doesn't advertise whether their programmer works with Linux. I don't have access to a windows box and I'd anyway rather do development on Linux. Will a PIC be a PITA to develop for?
     
  7. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    I use it in linux.

    You can use wine for most everyting, and a virtual box XP for everything else.
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,173
    1,797
    I would be surprised if you could actually write 24/96 data to an SD card. Flash write times will be a bottleneck.
     
  9. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Agreed. You will likely need a buffer.
     
  10. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    Audio data is surprisingly low data rate. 24/96 is only 750kb/s. Also, there are big write rate differences between cards (card classes to be exact). Or are you afraid that the PIC is unable to keep up the necessary throughput? .. even with dma?
     
  11. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Doesn't seem right. 750 is about the bitrate of a single channel of CD audio (1.411 Mbit/s) Unless your kb is kB/s, as S/PDIF can carry 7.2 audio channels (7 full bandwidth, 2 LFE only). Or is the .2 actually .1 fed to both LFE, and the 7 a DSP mix of 5.1?
     
  12. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    96kHz, two channels, four bytes per frame. That comes to 96000*2*4 = 750kB/s. Yes, I meant kilobytes. Also, I'm not interested in the surround formats.

    But ADAT would be interesting and require more bandwidth. But I'm going to settle for SPIDIF for now.
     
  13. Papabravo

    Expert

    Feb 24, 2006
    10,173
    1,797
    Isn't it
    Code ( (Unknown Language)):
    1.  
    2. 96,000 samples/second * 2 channels * 32 bits/sample/channel
    3. = 6,144,000 bits/second
    4. = 768,000 Bytes/Second
    5.  
    If it takes 10 milliseconds to write, not transfer the data, each 512 Byte sector to the SD card, how large a buffer will you need for three minute track?

    I calculate that writing that amount of data will take 45 minutes for a 3 minute track
    Code ( (Unknown Language)):
    1.  
    2. 768,000 bytes/second * 60 seconds/minute * 3 minutes = 138.24 Megabytes
    3. 138.24 Megabytes / 512 bytes/sector = 270,000 sectors
    4. 270,00 sectors * 0.010 seconds/sector = 2700 seconds = 45 minutes
    5.  
    Good luck finding a buffer that large on your dsPIC.
     
  14. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    Correct: 768000 bytes/second = 750kB/s (kB = 1024 bytes)

    How did you come up with 10 milliseconds to write 512 bytes? If you check http://en.wikipedia.org/wiki/SD_card#Speed_Class_Rating it's clear that even Class 2 cards are supposed to be able to store at that data rate. Is the transfer limited that much by the dsPIC?

    If you think the dsPIC can't handle it, do you have any other suggestions?
     
  15. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    What's the source of this data stream? Broadcast? CDs? DVDs?
     
  16. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
  17. Papabravo

    Expert

    Feb 24, 2006
    10,173
    1,797
    The dsPIC is limited by the amount of memory available to it. Under the conditions of a long write time for each sector you need a large buffer to hold the data while you are waiting for the sector writes to complete.

    10 milliseconds is a typical write time for a flash block. I'll look at the link and get back to you.

    Edit: I would cast a jaundiced eye at the following line from the link you provided:
    "...class speed ratings are quoted by the manufacturers and not verified by any independent evaluation process."
    Don't know about you but I wouldn't want to bet the farm on such a part until I had verified it. Good luck with that process.

    BTW the correct nomenclature is 750 KiB -- see the following article
    http://en.wikipedia.org/wiki/Kilobyte
     
    Last edited: Dec 7, 2010
  18. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    It'll be far to complex for someone without major hardware & software skills to build. You can buy one though.
    M-AUDIO Microtrack II
     
  19. aavikolla

    Thread Starter New Member

    Dec 6, 2010
    9
    0
    I have the necessary software skills. This project was to get experience with MCUs. But yeah, I just happened to bump into the microtrack II also, so maybe i'll get one and think of another project to learn about MCUs.

    As the microtrack shows, there is no bottleneck with SD cards. I have one SD card here which is capable of write speeds of multiple megabytes per second. I would however be interested in knowing if there are inherent throughput problems with (certain?) MCUs. The reason I originally was asking for native I2S support and DMA is to have as much hardware support for streaming the audio data from SPDIF to the SD card.
     
  20. Papabravo

    Expert

    Feb 24, 2006
    10,173
    1,797
    I myself am kind of curious as to how the flash speeds have been reduced so dramatically. The original reason for long FLASH write times relative to read times was the time it took to charge the capacitance of a floating gate. If that is no longer a limitation then I suspect the use of a different technology.
     
Loading...