Jump to content

Digital Audio Processor - PIC Processing Overhead Question...


Artesia

Recommended Posts

Hi,

I am looking into the possability of making a PIC powered SPDIF Signal 'processor'. The idea of this device; is to allow the adjustment of the signal sample frequency & bit depth in real time to give a sound to the processed signal much like early samplers.

Regarding the PIC18F452 - would it have sufficient data transfer rate to Receive a 16bit 44/48khz stereo SPDIF signal & then relay it on again ?

I could probably figure this if i did the math - though someone here may well know the answer to this already.

Further on this point, assuming that the pic can handle realying this information - i'd assume that it was within it's capability to then pull appart this data & then do a simple bit of math to then allow downsampling the frequency sample rate ?

If this is looks feasable (even if it means using a more powerful pic) i'll have a go at this sometime - should be a good way to get to grips with pic programming from scratch. Also - got afew more ideas on how to process the signal; so this could be a really fun project to toy with ! :)

Link to comment
Share on other sites

Hi Artesia,

this is perverse, isn't it? Reducing the bitrate on a interface which was invented for best digital quality? ;-)

(btw.: I would use a VST for such a simple job)

The datarate of SPDIF at 48kHz is 3.072  Mbit/s, this means that you have only 3 PIC instructions per bit - doesn't look feasible.

More infos here http://www.epanorama.net/documents/audio/spdif.html

Best Regards, Thorsten.

Link to comment
Share on other sites

All this squeaky clean sound conversion is great for transporting those sounds to and from the analog & digital domains. however it does little to add character to the sound ;) The essance of such a project would be  to encapsulate the elements of sound distortion + artifacts  inherent to varying imperfect transitions between these domains. The General problem with downsamplng ins software is that it tends to smooth the signal by applying a 'low pass' filter - rather than spitting it out raw. + other things like lower  bit  jitter sound interesting (think Casio CZ series).

Would be nice to have this as a stand alone widget  + ;)

With the versitility of simple manipulations the streams directly - i would assume that effects could be acheived which; somthing like Reaktor could not be hacked to do.

Anyway, as TK notes - not likely to be able to do anything useful with the standard MIOS pic.  Will Read up some more on this - maybe somthing could be done with another chip.

The resampling could at a guess be acheived by having enough memory to load a whole 'sample frame' into memory at once & then ignoring 'x' number of frames (in relation to the given sample freq) + giving the last read frame as the current frameset until this table is updated with the next frame that is read.

...hmm might need afew more mhz - but with a frame worth of memory this might work (?) :)

Thanks for the feedback - will ponder this...


Update #1:

With the information provided on TK's link (Ta !)  - the ammount of actual audio sample data in the various packets & sub packets brakes down like so:

[    SubFrame ]        16 bit SubFrame            = 16  bits            - (per SubFrame)

[          Frame ]        16 bits x 2 SubFrames  = 32  bits            - (per Frame)

[            Block ]     32 bits x 192 Frames      = 6,144 bits   - (Per Block)

A subframe is the smallest  packet of data 32 bits (16 bits 'reserved'  for the audio samples), which represents one sample frame for one audio channel. a bit flag is also assigned to say weather this frame belongs to the left or right channel; presumably the two 'Frame'  'SubFrames'  are the left & right channels.

[ 18F452 RAM ] 1536 Bytes  x 8  =  12,288 Bits

So,  when stripping the data down - There is  enough space in 18F452 RAM (1536 Byte) to store exactly 2 Blocks worth of data. Whilst ignoring the other (allbeit important) other non audio bits.

[    AllData OneBlock ]    32bit x 2 x 192 = 12,288 bits - (All Data Total Per a Block)

The datarate of SPDIF at 48kHz is 3.072  Mbit/s, this means that you have only 3 PIC instructions per bit - doesn't look feasible.

Now assuming that 3 instructions can be carried out during the period of one Bit of a SPDIF DataBlock arriving - then at 12,288 bits per a DataBlock  - this would leave the oppertunity to execute 36,684 instructions in this timeframe ! + theres enough ram to do some juggling with..

The real problem arrives when it comes to simaltainiously sending & Receiving that data - maybe two pics could resolve this by one dealing with stripping the data appart, whilst the other picks & repeats the raw data packets to create the desired result.

With the ammount of ram available on the 18f452 - this would allow for a 1 Block  lag - with higher memory capacity pics from this family; maybe upto 3-6 Block  lag could be used to borrow back time to do more instructions.

- Any Further  Thoughts on this matter anyone ? :)

Link to comment
Share on other sites

Hi,

it's a typical job for a FPGA (I'm writing this since I'm currently playing with a Xilinx Spartan3 development board ;-)

This means that you have to learn VHDL. Fortunately the SPDIF core doesn't need to be reinvented, it's already available at this site: http://www.opencores.com/projects.cgi/web/spdif_interface/overview

Best Regards, Thorsten.

Link to comment
Share on other sites

fair  comment :)

Looking into that - however the website is under too high a load this afternoon to churn out the downloadable bits :/

Been thinking some more about how this might be implimentable - and it occured that if  a datatable containing say 192 slots for subframes). Then a quite flexable stucture for manipulating the packet order in any way desired - could be acheived by having a outgoing 'subframe address read table'  with 192 freely editable address slots.

An example of how this might work with 16 slots for some examples:

(some of these examples would require streching over subframes to work  as intended)

(SubFrames stored as - F01 to F16 )

(F00 = Blank SubFrame)

Un-modifyed 'playback':

Read Line:  'play' Subframe no:

001              F01

002              F02

003              F03

004              F04

005              F05

006              F06

007              F07

008              F08

009              F09

010              F10

011              F11

012              F12

013              F13

014              F14

015              F15

016              F16

an example of what a downsamplng might look like with a 16 subframe table:

Read Line:  'play' Subframe no:

001              F01

002              F01

003              F01

004              F01

005              F05

006              F05

007              F05

008              F05

009              F09

010              F09

011              F09

012              F09

013              F13

014              F13

015              F13

016              F13

Then onto some other uses...

Playing time interval sections backwards:

Read Line:  'play' Subframe no:

001              F16

002              F15

003              F14

004              F13

005              F12

006              F11

007              F10

008              F09

009              F08

010              F07

011              F06

012              F05

013              F04

014              F03

015              F02

016              F01

'random' garbling :

(This implimentation would probably give a DAC a heart attack  ;)

Read Line:  'play' Subframe no:

001              F08

002              F11

003              F02

004              F15

005              F14

006              F10

007              F01

008              F06

009              F09

010              F03

011              F05

012              F12

013              F04

014              F16

015              F13

016              F07

Gapper effect :

Read Line:  'play' Subframe no:

001              F01

002              F02

003              F03

004              F04

005              F00

006              F00

007              F00

008              F00

009              F09

010              F10

011              F11

012              F12

013              F00

014              F00

015              F00

016              F00

Seudo Jitter :

Read Line:  'play' Subframe no:

001              F01

002              F02

003              F03

004              F04

005              F01

006              F02

007              F07

008              F08

009              F09

010              F10

011              F07

012              F08

013              F13

014              F14

015              F15

016              F16

Seudo Stutter :

Read Line:  'play' Subframe no:

001              F01

002              F02

003              F03

004              F04

005              F01

006              F02

007              F03

008              F04

009              F09

010              F10

011              F11

012              F12

013              F09

014              F10

015              F11

016              F12

Playing a time interval section in a 'cyclic' loop :

Read Line:  'play' Subframe no:

001              F01

002              F02

003              F03

004              F04

005              F05

006              F06

007              F07

008              F08

009              F08

010              F07

011              F06

012              F05

013              F04

014              F03

015              F02

016              F01

Playing time interval sections in a 'cyclic' loop :

Read Line:  'play' Subframe no:

001              F01

002              F03

003              F06

004              F08

005              F10

006              F12

007              F14

008              F16

009              F16

010              F14

011              F12

012              F10

013              F08

014              F06

015              F03

016              F01

Shuffle':

Read Line:  'play' Subframe no:

001              F01

002              F02

003              F13

004              F14

005              F05

006              F06

007              F09

008              F10

009              F07

010              F08

011              F11

012              F12

013              F03

014              F04

015              F15

016              F16

hmm - crazy im sure ...But playing with editable lookup tables could provide a whole lot of fun methinks :)

even without  modifying the packet contents :]

Link to comment
Share on other sites

'Task for a dsp pic...' No and possibly yes...

The idea of this is to take truely base level approach to manipulating the audiostream itself. Which isn't something that the run of the mill dsp chip would automatically lend itself to (?). Idea being, to see what wonderful & awful things can be done by mashing up the order of the actual audio packets in realtime (like 'shuffling a pack of cards') - something which i don't think anyone has tried yet...

maybe a dsp pic could lend itself to this; But given they seem to be for just running algorythms in a somewhat more restricted framework - maybe not.

Thornsten's suggestion for a suitable platform is probably the best line to start trying this one out i guess :)

Link to comment
Share on other sites

It definitely is - just to give you an impression: I've synthesized the spdif_tx unit with some additional circuirity which intitializes the SFRs. The logfile says that ca. 10% of the FPGA is allocated, and that it runs with up to 180 MHz. However, in pratice you've to take care for the tx clock frequency, because it must be divitable by the bitrate, thats currently my blocking point (have to wait for the next Reichelt order to get some parts for a PLL)

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...