Home AMX User Forum NetLinx Studio

Kindergarten level programming

Hi,

Anyone willing to help?

I'm trying to make an AMX TP button ramp an amp channel up whilst it's pressed.

If I send the string once, it increments the volume 1db at a time. So I've tried to create a TO Command to repeat the sending.

DEFINE_CALL 'Surround Amp Up'
{
IF(SURROUND_AMP_UP)

WAIT 2
SEND_STRING dvSURROUND, "$50, $43, $53, $45, $4E, $44, $02, $04, $80, $70, $C7, $38, $47, $48"
}

BUTTON_EVENT[dvTP1,11]
{
PUSH:
{
TO[dvTP1,11]
TO[SURROUND_AMP_UP]}
}

I'm a novice, playing at home, so be nice please :)

Comments

  • This code has not been tested, but in general this is what I do with Volume Ramping.
    DEFINE_VARIABLE
    Integer dvTP1_ButtonHold;
    
    Define_Function SurroundAmpUp(Dev Device)
    {
    	//Should be putting this into a Queue and firing out in a Timeline
    	//@ a predetermined interval
    	SEND_STRING Device, "$50, $43, $53, $45, $4E, $44, $02, $04, $80, $70, $C7, $38, $47, $48";
    }
    DEFINE_EVENT
    BUTTON_EVENT[dvTP1, 11]
    {
    	PUSH:
    	{
    		dvTP1_ButtonHold = False;
    	}
    	RELEASE:
    	{
    		if ( !dvTP1_ButtonHold )
    		{
    			TO[Button.Input];
    			SurroundAmpUp(dvSURROUND);
    		}
    		dvTP1_ButtonHold = False;
    	}
    	HOLD[2, REPEAT]:
    	{
    		dvTP1_ButtonHold = True;
    		TO[Button.Input];
    		SurroundAmpUp(dvSURROUND);
    	}	
    }
    
  • TonyAngeloTonyAngelo Posts: 315
    Another method

    When needing to ramp volume like this I use timelines.
    DEFINE_VARIABLE
    
    LONG lVolumeDelay[]={150}
    INTERGER nVolRamping
    
    DEFINE_EVENT
    
    BUTTON_EVENT[vdvTP_Vol,nVolBtn]
    {
         PUSH:
         {
              IF(!nVolRamping)
              {
                   nVolRamping=1
                   // send the ramp volume command
                   TIMELINE_CREATE(tlVolRamp,lVolumeDelay,1,TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
              }
         }
         RELEASE:
         {
              nVolRamping=0
              TIMELINE_KILL(tlVolRamp)
         }
    }
    
    TIMELINE_EVENT[tlVolRamp]
    {             
        // send the ramp volume command
    }
    
  • the8thstthe8thst Posts: 470
    TonyAngelo wrote: »
    When needing to ramp volume like this I use timelines.
    DEFINE_VARIABLE
    
    LONG lVolumeDelay[]={150}
    INTERGER nVolRampingTimeOut = 30
    
    DEFINE_EVENT
    
    BUTTON_EVENT[vdvTP_Vol,nVolBtn]
    {
         PUSH:
         {
              IF(!timeline_active(tlVolRamp))
              {
                   // send the ramp volume command
                   TIMELINE_CREATE(tlVolRamp,lVolumeDelay,1,TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
              }
         }
         RELEASE:
         {
              TIMELINE_KILL(tlVolRamp)
         }
    }
    
    TIMELINE_EVENT[tlVolRamp]
    {             
        if (timeline.repetition < nVolRampingTimeOut)
               // send the ramp volume command
        else
               timeline_kill(tlVolRamp)
    }
    

    I made couple small changes. I got rid of the integer variable because it is redundant, and I added a guard against runaway volume if a button release is missed (habit from R4 days).
  • DHawthorneDHawthorne Posts: 4,584
    Not saying it's wring, because it's a perfectly valid approach, but I've personally always felt timelines were overkill. I use the HOLD [REPEAT, n] method. You can adjust the repeat value if the serial port overruns or keeps going too long; if you buffer your commands, you can also clear the queue on a RELEASE. My problem with serial devices has always been, however, that unless there is a built-in ramp command, it's really fussy to get the ramping to go smoothly without overruns.
  • huttencmhuttencm Posts: 23
    I am with Dave, try this

    BUTTON_EVENT [dvKP,9] // SELECT Volume Up KEYPAD BUTTON (#9)
    {
    HOLD[2,REPEAT]:
    {
    IF (nVol_Lvl < 100)
    {
    PUT YOUR STRING HERE
    nVol_Lvl = nVol_Lvl + 1
    ON [dvKP,9]
    }
    }
    RELEASE:
    {
    OFF [dvKP,9]
    }
    }
Sign In or Register to comment.