Shop OBEX P1 Docs P2 Docs Learn Events
Demo board audio examples? — Parallax Forums

Demo board audio examples?

SSteveSSteve Posts: 808
edited 2006-05-24 18:58 in Propeller 1
Is there any example code for using the audio output or the electret mic on the propeller demo board?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-05-18 06:56
    Here's a program that runs on the new Propeller Demo Board, Rev C.

    It digitizes the microphone to selectable resolutions and then outputs the samples to the headphones. It uses one COG. The COG's CTRA is used for analog-to-digital conversion and its CTRB is used for digital-to-analog conversion.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • SSteveSSteve Posts: 808
    edited 2006-05-19 04:37
    Thanks, Chip. I didn't expect that to be so compact. I guess the counter control registers are very powerful. The only problem is I have no idea what they're doing. smile.gif

    I've done audio programming before, but from the application level. I was sending and reading buffers full of sample values to/from sound card drivers. Is there a good resource you'd recommend I study to try to figure out what's going on here? Do I need to go to the storage locker and break out my venerable copy of Musical Applications of Microprocessors?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • cgraceycgracey Posts: 14,133
    edited 2006-05-19 06:27
    Ssteve,
    Here's a spin program that documents the counter configuration and synthesizes two different frequencies simultaneously. It·was posted earlier on another thread.
    Sound programming is my favorite. I want to make a speech synthesis object for the Propeller that can sing, too. We've only got 32KB of RAM in the chip, so algorithmic programming is key to making big things happen. I have no recommendation on what to read, by the way.
    Have fun!
    SSteve said...
    Thanks, Chip. I didn't expect that to be so compact. I guess the counter control registers are very powerful. The only problem is I have no idea what they're doing. smile.gif

    I've done audio programming before, but from the application level. I was sending and reading buffers full of sample values to/from sound card drivers. Is there a good resource you'd recommend I study to try to figure out what's going on here? Do I need to go to the storage locker and break out my venerable copy of Musical Applications of Microprocessors?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • GadgetmanGadgetman Posts: 2,436
    edited 2006-05-19 07:38
    Chip Gracey (Parallax) said...
    Sound programming is my favorite. I want to make a speech synthesis object for the Propeller that can sing, too. We've only got 32KB of RAM in the chip, so algorithmic programming is key to making big things happen.
    You know...
    If you manage to pull that trick, you're going to make a lot of dedicated speech-chips obsolete real fast.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • SSteveSSteve Posts: 808
    edited 2006-05-19 08:32
    Ok, I think I'm figuring out how the counters are working. I guess the thing I really don't understand is how a Delta-Sigma Digitizer works. Do you know of any good references for that?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-05-19 12:46
    Heres a paper aptly named "Are SD ADCs Greek to You?"

    but if your not familiar with signal theory even the explanation may sound greek. Unfortunately nearly all explanations are at this higher level, that is because sigma-delta converters are not a first generation ADC, so everyone assumes you've studied and understood the first generation ADCs.

    This is the key phrase "In both cases, the density of ones in the serial digital output is proportional to the input signal value." So what it is doing in the most general terms is creating a PWM signal which represents the analog value, this signal is digitally averaged to produce the digital representation of the analog value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    1+1=10

    Post Edited (Paul Baker) : 5/19/2006 12:57:38 PM GMT
  • cgraceycgracey Posts: 14,133
    edited 2006-05-19 16:15
    The way the Propeller ADC works is by balancing the charge on the cap to the threshold voltage. If a high voltage comes in, it must output lows to keep the pin at the threshold. The converse is true for low voltages. The analog measurement is realized by how many 0's had to be output to counteract the incoming voltage. If you did 100 cycles of feedback (100 clocks' worth) and you output 0's 63 times, then your sample is 63 out of 100. Of course, for math reasons it's nice to stick to powers of two for cycle counts, since this maximizes the usage of binary numbers.
    SSteve said...
    Ok, I think I'm figuring out how the counters are working. I guess the thing I really don't understand is how a Delta-Sigma Digitizer works. Do you know of any good references for that?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • SSteveSSteve Posts: 808
    edited 2006-05-19 17:03
    Paul: Thanks a bunch for the article reference. I will dig in and see what I can get out of it.

    Chip: Thanks for the explanation. It really sheds a lot of light on what's going on. I think it tells me enough to make some attempts at generating audio.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-05-23 17:20
    This demo has a verry high output.
    I would like to have a crosscoupled counter to generate sine/cosine data at some audio frequency and then scale for volume befor outputing to a PWM DAC that cycles above audio frequencys.
    But I need more information on the counter modules for PWM operation.
    The crosscoupled counter to generate sine/cosine data is probably going to be to complex for the CTRA/CTRB since it involves scaled cross feedback, and needs to be in assembly .

    Is there more info on the counter modules for PWM and DAC ?
  • cgraceycgracey Posts: 14,133
    edited 2006-05-24 16:04
    To do what you're talking about, you would use one counter to generate the duty modulation for sine and another for cosine. Software would perform the sine/cosine lookups from ROM, perform the·scaling, and then the·WAITCNT instruction would be used to time your software loop. I'll try to write such an object so you could see what I'm talking about. It's pretty straightforward. To summarize:

    1) The counters get used to delta-modulate I/O pins for DAC purposes.

    2) Software performs ROM lookups and scaling for the DAC samples.

    3) The system counter is used as sync mechanism via the WAITCNT instruction to re-run the sample/scale/output loop at a certain frequency.
    Phillip Y. said...
    This demo has a verry high output.
    I would like to have a crosscoupled counter to generate sine/cosine data at some audio frequency and then scale for volume befor outputing to a PWM DAC that cycles above audio frequencys.
    But I need more information on the counter modules for PWM operation.
    The crosscoupled counter to generate sine/cosine data is probably going to be to complex for the CTRA/CTRB since it involves scaled cross feedback, and needs to be in assembly .

    Is there more info on the counter modules for PWM and DAC ?
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-05-24 18:22
    With both sine and cosine I could display a XY format on my ocilloscope and get a nearly round display figure, and use persistance mode to see the data noise spread.
  • rokickirokicki Posts: 1,000
    edited 2006-05-24 18:58
    Hmm, so during an analog to digital conversion, we're essentially holding one input pin (the sampling pin) right at the
    input threshold to the propeller chip? What will that do to the current consumption of that input buffer? Is there
    hysteresis on the input? If so, how many millivolts? I'll have to scope those pins and see what's going on in there.

    Those counters sure are flexible. I'm going to have to study this stuff a whole lot more.
Sign In or Register to comment.