Announcement

Collapse
No announcement yet.

snd_Freq() and AUIO_ENABLE

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • snd_Freq() and AUIO_ENABLE

    I'm trying to control the AUDIO_ENABLE pin manually using pin_HI(AUDIO_ENABLE) and pin_LO(AUDIO_ENABLE) prior to and after the call to snd_Freq(x,y) and it does not work.
    If I try and manually control it the sound output stops working.in various ways.
    pin_HI( AUDIO_ENABLE);
    snd_Freq(300, 30);
    pin_LO(AUDIO_ENABLE);

    If I comment out the pin_HI and pin_LO lines then the output works but the AUIDIO_ENABLE signal stays hi
    If I uncomment the pin_LO then the AUDIO_ENABLE signal stays low and there is no sound as a result
    If I uncomment the pin_HI by itself and keep the pin_LO commented out, then the AUDIO_ENABLE signal stays hi, but the AUDIO_OUT stays low and there is no sound as a result.
    If I uncomment both the pin_HI and the pin_LO lines, then the AUIO_ENABLE signal toggles hi and low, but the ADIO_OUT signal stays low and again there is no sound as a result.
    What is going on?
    I want to be able to turn off the amplifier after creating a button chirp sound.

  • #2
    Hello,

    As stated ont his forum thread:

    Audio support on gen4 devices
    https://forum.4dsystems.com.au/node/54117

    The amp is turned on automatically when audio is played
    I tested this snippet with a MOTG AC 2 as an external amplifier and it seem to have worked fine.
    Code:
        txt_MoveCursor(0,0);
        print("AUDIO ENABLE","\r\n");
        //pin_HI( AUDIO_ENABLE);
       // pause(1000);
        print("Play Sound","\r\n");
        snd_Freq(300, 30);
        print("AUDIO DISABLE","\r\n");
        pin_LO(AUDIO_ENABLE);
        pause(5000)
    The sound played and the Audio enable pin was set to low.

    Best regards,
    Michael

    Comment


    • #3
      I am using a gen4-uLCD-43DT SB.
      If I try and run the following code. I will not get any sound. If you look at the signals w/ a scope you will see that the AUDIO_OUT signal is functioning, but the AUDIO_ENABLE stays low disabling the amplifier.

      func buttonChirp()
      /// pin_HI( AUDIO_ENABLE );
      /// snd_Volume( 127 );
      snd_Freq( 300, 30 );
      pin_LO( AUDIO_ENABLE );
      endfunc


      Comment


      • #4
        Hello,

        Have you tried adding a pause between the snd_Freq(300,30) and pin_LO(AUDIO_ENABLE)?
        Code:
           snd_Freq( 300, 30 );
           pause(30);
           pin_LO( AUDIO_ENABLE );
        This seems to have worked for me.
        I think the error on your previous code is that snd_Freq(); is not given enough time to finish and the audio enable pin was set to low prematurely.

        you could also use while(snd_Playing()); in place of the pause, this ensures that the sound finishes playing before doing subsequent operations.
        Last edited by michael_4D; Yesterday, 02:32 PM.
        Michael

        Comment

        Working...
        X