Shop OBEX P1 Docs P2 Docs Learn Events
Useful things to do with pcm data samples. Ideas would be great, thanks. — Parallax Forums

Useful things to do with pcm data samples. Ideas would be great, thanks.

KyeKye Posts: 2,200
edited 2009-08-22 02:19 in Propeller 1
Hey guys. I've been working on a PCM DAC and ADC driver for the prop to supplement the drivers seen in the audio section of the obex. So far I've had great results and everything seems to just work.

The DAC and ADC are each 8 bits and have great quality for the minal amount of hardware and cost they take.

...

So, the driver is attached along with some wav files from Rayman's wave player. Using my driver, playing them is more than trival.

...

Now, I'm interested in knowing from anyone who has done anything with audio what other little extra's can I add to this driver.

I'm thinking about volume control for the DAC and possibly a built in averaging function for the·ADC so the user can get back averaged samples instead of raw samples and the ability to choose as many to be averaged as they want.

Is there anything else that would be really useful that I could offload into the driver that the average user would like?

Thanks for your input.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Comments

  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-08-20 21:49
    Kye,
    Do you ever sleep ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    'Those who can, do.Those who can’t, teach.'
    'Convince a man against his will, he's of the same opinion still.'

    ·
  • David BDavid B Posts: 592
    edited 2009-08-20 22:11
    I don't know if this would be of general interest, but once when I was playing around with stereo WAV player code, by accident I got some really weird echo and inside-a-giant-tin-can effects by playing the same data on two channels, with varying amounts of delay between the channels.

    Also, being able to vary the playback speed is fun for experimenting with sounds.

    So maybe some kind of audio laboratory would be an interesting project?
  • KyeKye Posts: 2,200
    edited 2009-08-20 23:25
    Um? What...

    I'm asking people more about any processing effects that I can offload from the spin code. Like averaging samples or finding the min of all the samples of the max of all the samples.

    I don't really know what's useful, that's why I'm asking here on the forum.

    ...

    And yes I do sleep. All the drivers I've been talking about are just being repolished again. They were done a while ago. Addtionally driver programing has made me very good at programing. smile.gif

    ...

    Please look at the driver first if you have suggestions. I already have a pretty good set of features. The driver is mono only however.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 8/21/2009 12:03:54 AM GMT
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-08-20 23:49
    Nice work, Kye!

    (And I'd like to second the nomination for "great commenting" that was mentioned over in the
    "Newbie thoughts.... Are my code commenting expectations for demo programs to high?" thread!)

    > I'm asking people more about any processing effects that I can offload from the spin could

    into PASM?

    You know, DavidB's suggestion immediately before of an 'audio lab' is a pretty cool idea. The prop can handle simple audio, it's easy to work with, and audio is just fun because it's sort of instant gratification ... when you tweek a parm, you hear the results. Things that would be useful would be things that help you learn how digital audio works... from simple things like peak detectors (the max sample) to the top of the noise floor (min sample)... or say mixing of two or more signals (summing and averaging) etc. ... from simple things like that, to doing Fast Fourier Transforms (audio spectrum analyzer) --- already in the OBEX yes, but still there's a lot of room for new things.

    This would be a nice educational thing too - I know you're not thinking that big, but the PropEducation Kit and the Basic Stamp Signals books/kits touch on these things only superfically ... a course on audio would be way cool - and probably interesting to a lot of people.

    So the more you do, the more material there would be for something like that.

    Just wanted to encourage you!

    cheers
    Howard

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • KyeKye Posts: 2,200
    edited 2009-08-21 00:01
    Thanks, I'm also·thinking about adding built in·thresholding and maybe max and min.

    The ADC outputs 128 as the middle value however so you would have a min at say 120 and a max at say 135 to prevent false triggering. However the pasm already divides down the raw sample from the ADC so your min and max thresholds wouldn't need to be more than 10 above or below to prevent that stuff.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 8/21/2009 12:08:18 AM GMT
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-08-21 00:26
    > adding built in thresholding and maybe max and min.

    Kye, yes that's a good idea.

    > the pasm already divides down the raw sample from the ADC

    I've just started studying your code. What's the routine name that does that, is it "divideLoop" or is it in the defines (line 286):
    ADCDAC long ((|<((DAC_Pin <# 31) ... ?

    A tangent: It'd be nice to use your PCM techniques to generate the equivalent of 16bit samples ... interesting ... the buffers are pretty small. This is nice, tight code you've written. You think it could be tweaked up to 48kHz / 16bit samp.size without hitting the wall?

    thanks again.

    - H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • KyeKye Posts: 2,200
    edited 2009-08-21 01:30
    Actually 96Khz is the upper limit I believe. But, even then I could go higher.

    The driver takes the raw ADC value which can go as high as the (clkfreq / sampleRate) and then divides that value by 256. Then I divide the value that comes out of the ADC by ((clkfreq / sampleRate) / 256). This scales the value from the ADC back down to a value between 0 to 255.

    This ( ADCDAC long ((|<((DAC_Pin <# 31) ... ? ) opens the DIRA port.

    The sigma delta ADC doesn't produce 16 bits amples over 1200 Hz sample rate. 8 bit samples are the only safe samples.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-08-21 10:35
    Hello Kye,

    I have some ideas:
    I have no practical use for these ideas just thinking about what COULD be done as a wild brainstorming that doesn't care at all about making sense ot how difficult it would be to program it

    some kind of DSP

    an adjustable threshold menaing not beeing fixed on 128 +- the same value but adjusting threshold to to 30 toleranz downwards -10 and tolerance upwards +160 or whatever

    frequency measuring, low-high-time measuring or calculating the low/high ratio
    different threshold-tolerances for low and high-level

    - automatic offset adding/substracting
    - a configurable monoflop functionality to another IO-pin
    - a configurable monoflop-filter meaning measuring the voltage and only beeing over a threshold for a configurable time set output high (= supressing or disregard short peaks)
    - or the other way round only pay attention to short peaks between 0 microseconds and 150 microseconds or 310 µsecs and 450 µsecs
    - averaging x samples and then start a new averaging period 1st average use sampls 1..10; 2nd average use samples 11...20, etc. etc.
    - averaging continuosly first average using sample 1..10; 2nd average using sample 2..11, 3rd sample 3...12, etc, etc,
    - some kind of phaseshifting


    is it possible to increase resolution at a high speed using two cogs ?
    I haven't underestand in detail how the delta-sigma adc works so maybe this is nonsense
    or not doable with the delta-sigma-circuit what I write next
    charging and discharging the capacitors takes time.
    If the circuit is extended in some way

    example:
    the voltage to be measured is 1,137V
    one part measures it is "around 0V, 0,1V, 0,2V, .... 3,2V 3,3V and then another part of the circuit adjusts to 1,100 V so a resulting
    voltage between measured input is 1,137V - 1,100V = 0,037V and then the full range of digital 8 bits can be used on 0V-0,099V giving a higher resolution
    without increasing frequencies ?

    best regards

    Stefan
  • KyeKye Posts: 2,200
    edited 2009-08-21 13:59
    Those are good ideas.

    Thanks,

    The sigma delta ADC has a sample resoultion of (clkfreq / sampleRate). So, if you sample it less it has more resoltuion. If you sample it more it has less. 8 bit values however work even pass 96 KHz which I think I'll make my upper limit. That's why I use them. The DAC could be 32 bits... but 8 bit resolution keeps things simple.

    However spin cannot sample the 96Khz data coming from the ADC. So using averaging you can bring that value down to lets say 12000 Hz if you average 8 samples at a time. I believe that would be really useful.

    ...

    I'm not really sure how to do DSP. I don't really know anything about it. But that's for the ideas.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 8/21/2009 2:38:01 PM GMT
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-08-21 14:28
    Hmmm.. somehow I see Propeller-based mod tracker coming out of this..

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • KyeKye Posts: 2,200
    edited 2009-08-21 14:33
    Oh, I know. I can add into the DAC a phase shift delay like as stefan mentioned to create all those nice audio effects like flanging and echo and chorus or whatever.

    I don't belive the driver will do anything in the frequency range but adding in a delay would be simple enough. It would put to good use the rest of the cog's memory.

    But, since samples are 8 bits I'll need to think about how I add the signals back again. so as to not go over the max limit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-08-22 02:19
    Oldbitcollector said...
    Hmmm.. somehow I see Propeller-based mod tracker coming out of this..
    OBC,·is that the same as an old·mod player?
    ...·wrote a simple one·years ago on win98 - lot's of fun.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.