Shop OBEX P1 Docs P2 Docs Learn Events
Detect audio from microphone on the PropBOE — Parallax Forums

Detect audio from microphone on the PropBOE

JasonFogliaJasonFoglia Posts: 5
edited 2014-09-15 18:03 in Propeller 1
How do I detect audio from microphone on the PropBOE?

C/C++ examples referred or spin is ok.

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-09-15 06:30
    How do I detect audio from microphone on the PropBOE?

    Meaning the presence of "audio" past some threshold, or some particular frequency, what have you in mind?
  • JasonFogliaJasonFoglia Posts: 5
    edited 2014-09-15 09:44
    Well, I guess my question should have been.
    Is there examples of how to use the microphone on the PropBOE?

    I guess an example would be receiving frequencies from the mic, or maybe I guess recording sound to an SD card or maybe something simpler like sending the sound from the mic to speakers.
    I've already worked on working examples for using the output audio jack and a speaker, but I've searched high and low for a simple microphone example.

    Thanks for any help!
  • RaymanRayman Posts: 14,655
    edited 2014-09-15 09:56
    I did this little "Parrot" demo a while ago:
    http://forums.parallax.com/showthread.php/105292

    It records via microphone and then plays back via audio output.
    If you change the pin #s to match BOE, it should work...
  • RaymanRayman Posts: 14,655
    edited 2014-09-15 10:14
    Also, Phil Pilgrim posted a demo of voice recognition that seemed to work nicely...
  • JasonFogliaJasonFoglia Posts: 5
    edited 2014-09-15 10:17
    Thanks Rayman, I'll give this a try later on.
  • ratronicratronic Posts: 1,451
    edited 2014-09-15 10:39
    Jason I modified the Microphonetoheadphone program for the demo board to work with the PropellerBOE. It's a little Spin.
    ' modified 9/15/14 Dave Ratcliff from the Propeller tool to use with PropellerBOE
    ' The microphone is digitized and the samples are played on the headphones.
    
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    
    ' At 80MHz the ADC/DAC sample resolutions and rates are as follows:
    '
    ' sample   sample               
    ' bits       rate               
    ' ----------------              
    ' 5       2.5 MHz               
    ' 6      1.25 MHz               
    ' 7       625 KHz               
    ' 8       313 KHz               
    ' 9       156 KHz               
    ' 10       78 KHz               
    ' 11       39 KHz               
    ' 12     19.5 KHz               
    ' 13     9.77 KHz               
    ' 14     4.88 KHz               
                                    
      bits = 11               'try different values from table here
      
    
    PUB go
    
      cognew(@asm_entry, 0)   'launch assembly program into a COG
    
      
    DAT
    
    '
    '
    ' Assembly program
    '
                  org
    
    asm_entry     mov       dira,asm_dira                   'make pins 8 (ADC) and 0 (DAC) outputs
    
                  movs      ctra,#20                         'POS W/FEEDBACK mode for CTRA
                  movd      ctra,#21
                  movi      ctra,#%01001_000
                  mov       frqa,#1
    
                  movs      ctrb,#26                        'DUTY DIFFERENTIAL mode for CTRB
                  movd      ctrb,#27
                  movi      ctrb,#%00111_000
                  
                  mov       asm_cnt,cnt                     'prepare for WAITCNT loop
                  add       asm_cnt,asm_cycles
    
                  
    :loop         waitcnt   asm_cnt,asm_cycles              'wait for next CNT value (timing is determinant after WAITCNT)
    
                  mov       asm_sample,phsa                 'capture PHSA and get difference
                  sub       asm_sample,asm_old
                  add       asm_old,asm_sample
                                                             
                  shl       asm_sample,#32-bits             'justify sample and output to FRQB
                  mov       frqb,asm_sample
        
                  jmp       #:loop                          'wait for next sample period
    '
    '
    ' Data
    '
    asm_cycles    long      |< bits - 1                     'sample time
    asm_dira      long      $c200000                        'output mask
    
    asm_cnt       res       1
    asm_old       res       1
    asm_sample    res       1
    
    {{
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474;                                                   TERMS OF USE: MIT License                                                  &#9474;                                                            
    &#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
    &#9474;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation    &#9474; 
    &#9474;files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,    &#9474;
    &#9474;modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software&#9474;
    &#9474;is furnished to do so, subject to the following conditions:                                                                   &#9474;
    &#9474;                                                                                                                              &#9474;
    &#9474;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.&#9474;
    &#9474;                                                                                                                              &#9474;
    &#9474;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE          &#9474;
    &#9474;WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR         &#9474;
    &#9474;COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,   &#9474;
    &#9474;ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                         &#9474;
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;c
    
  • JasonFogliaJasonFoglia Posts: 5
    edited 2014-09-15 17:35
    Thanks Dave,

    I had thought, I tried this code before. I'm might have gotten the pins mixed up.
    It's working now with your help of course!
  • ratronicratronic Posts: 1,451
    edited 2014-09-15 18:03
    I'm glad you have it working and welcome to the forums.
Sign In or Register to comment.