Shop OBEX P1 Docs P2 Docs Learn Events
Emic Sound Module: Volume Adjust --Help — Parallax Forums

Emic Sound Module: Volume Adjust --Help

stuartXstuartX Posts: 88
edited 2012-02-11 12:32 in General Discussion
Hi all,
I know this subject has been hashed out in the past. But, I check the post and did not see this specific request. I connected and used the example code for the Emic board and it works fine.
What I'm trying to do is adjust the volume and that's not working (its my code). I tried different examples and still can't get the volume to change. I also tried reset as well.
Can someone tell me what I'm doing wrong please? The code is below.

THIS CODE WORKS:

Tx PIN 0 ' connects to Emic SIn
Rx PIN 1 ' connects to Emic SOut
Busy PIN 2 ' 1 = busy


'
[ Constants ]

#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
Baud CON 396 ' 2400 baud, N81
#CASE BS2SX, BS2P
Baud CON 1021
#ENDSELECT

Yes CON 1
No CON 0

' Emic Commands (Hex Mode)

Say CON $00 ' say Engish text
Volume CON $02 ' set volume, 0 - 7
Speed CON $04 ' set speed, 0 - 4
Pitch CON $03 ' set pitch, 0 - 6
AddAbbr CON $04 ' add abbreviation
DelAbbr CON $05 ' delete abbreviation
ListAbbr CON $06 ' list abbreviations
Version CON $07 ' get version
Reset CON $08 ' soft reset
Audio CON $09 ' enable audio in
PhT CON $10 ' start of phonetic text
Help CON $FE ' display help
EOM CON $AA ' end of message

OK CON $55 ' "okay" for hex mode

'
[ Program Code ]

vol VAR Byte
response VAR Nib

Main:
GOSUB Check_Busy
SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
PAUSE 100
Check_Busy:
PAUSE 1 ' allow busy to activate
' DO WHILE (Busy = Yes) : LOOP ' wait until not busy
RETURN

Set_Volume:
vol = 2
SEROUT TX, Baud, [Volume, DEC1 vol, EOM] ' send to Emic
GOTO Main
END
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

When I replace Main with the following to adjust volume, it does not work:

Main:
GOSUB Set_Volume
GOSUB Check_Busy
SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
PAUSE 100


Help is appreciated.
Thanks (in advance)

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-11 10:18
    I notice the constant "Volume" is set to an incorrect value.
    Volume CON $02 ' set volume, 0 - 7
    

    Should be:
    Volume CON [COLOR=#ff0000]$01 [/COLOR]' set volume, 0 - 7
    

    $02 is used to adjust speed.
  • stuartXstuartX Posts: 88
    edited 2012-02-11 10:53
    Would this allow me to set my volume vol to any number (between 0 and 7) and dynamically adjust my volume?
  • stuartXstuartX Posts: 88
    edited 2012-02-11 11:02
    I changed the Volume CON to "$01". I still wasn't able to change the volume.
    I also tried the:
    SEROUT TX, Baud, [Volume, DEC1 vol, EOM] ' send to Emic
    to adjust the volume....still no luck.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-11 11:23
    It looks like the "Check_Busy" routine doesn't do much.

    Try adding a "PAUSE 500" after setting the volume and before trying to have the emic say anything.

    Make sure you set the "vol" varible before using the SEROUT command.

    Another thing you could try is:
    SEROUT TX, Baud, ["volume=2;"]
    PAUSE 500
    SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
    
  • stuartXstuartX Posts: 88
    edited 2012-02-11 11:47
    I applied the code and place in a lower volume of 1 (also tried other values between 1 and 7), but the volume level remains the same.

    code:
    [code]

    Main:

    GOSUB Check_Busy
    vol = 1 ' set pgm vars to defaults
    SEROUT Tx, Baud, ["volume=1;"]
    PAUSE 500
    SEROUT Tx, Baud, [Say, "1 2 3 Testing.", EOM]

    END

    [code/]
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-11 11:56
    You are just a little off with your code blocks. Instead of "[code/]' use "[/code]".

    I use a Emic a lot but I generally just leave the volume at 7 and adjust the volume on the speakers (built into the VGA monitor I use with a Prop).

    I don't think I've ever tried to dynamically adjust the volume with commands to the Emic.

    What is your sound circuit like? Are you using the "AOUT" pin or the "SP-" and "SP+" pins?

    I personally don't use Basic Stamps anymore so I'm not very sure about any Stamp code I may offer.
  • stuartXstuartX Posts: 88
    edited 2012-02-11 12:03
    I appreciate your help very much.
    How do I know if my volume is set to 7?
    When I read through the pdf it says it defaults to 3 or 4.
    If I can make it set to a particular volume, I'm good with that. The dynamic volume was just me testing.
    I connected my speaker to the "SP-" and "SP+".
    I also tried the "AOUT", but thats just a set volume which I don't think adjust. ( just for amplifier output according to the pdf, if i read correctly).
    Thanks for the block explanation. Just to be sure...Do i use [/code] for the beginning of the code and [/code] at the end of the code?
  • stuartXstuartX Posts: 88
    edited 2012-02-11 12:16
    Hey this works. I look at the pdf again and with your input:
    I noticed that adjusting the vol changes the volume. Adjusting the "volume" in the serout cmd does not change.
    [/code]

    GOSUB Check_Busy
    vol = 7 ' set pgm vars to defaults
    'SEROUT Tx, Baud, ["volume=1;"]
    SEROUT Tx, Baud, [Volume, DEC1 vol, EOM]
    PAUSE 500
    SEROUT Tx, Baud, [Say, "1 2 3 Testing.", EOM]

    END
  • stuartXstuartX Posts: 88
    edited 2012-02-11 12:20
    Also,
    It appears that the "Volume" in the SEROUT command adjust the volume for the AOUT pin of the EMIC.

    Thanks again for all your FAST help. I was trying to figure this thing out for hours!!
    Thank you very much.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-11 12:22
    stuartX wrote: »
    How do I know if my volume is set to 7?

    I assume it's at 7 because I just copied this code from the Emic Propeller demo.
      emic.SetVolume("7") 'loudest
     
    

    I've just left that part of the code alone ever since I started using an Emic (a couple of years ago).
    stuartX wrote: »
    Do i use [/code] for the beginning of the code and [/code] at the end of the code?

    You use [/code] at the end of your code and [code] at the beginning.

    I have a second Emic that I've wanted to use with a robot. (The first Emic is used with my data logging equipment. I don't want to mess with that one.) I'll test out my 2nd Emic with an 8 ohm speaker to make sure I can really adjust the volume. I'll let you know what I find out.
  • stuartXstuartX Posts: 88
    edited 2012-02-11 12:32
    Duane,
    Check my post before yours, I have the right syntax working now. You can refer to that if you use the stamp.
    Thanks for all your help.
    Thanks for the code block help also.
    I have three EMIC which I bought a few years ago. I'm using one for my robot. As an amplifier, I hacked a Lego amplifier which is perfect.
    I connected an 8 ohm speaker with it also. The volume adjust work. But if its outside or around additional ambient sound, an amplifier is needed.
    If I can help in any way, let me know, I learned through my mistakes...lol.
    Let me know how it goes with your 2nd Emic.
Sign In or Register to comment.