User Forum    :: Powered by YaBB
  « MIDI-OX User Forum - Mapping a toggle button »
Welcome, Guest. Please Login or Register.
Oct 22nd, 2024, 1:59am


Home Home Help Help Search Search Members Members Login Login Register Register


   MIDI-OX User Forum
   MIDI-OX
   Mapping Questions
(Moderator: Jamie OConnell)
   Mapping a toggle button
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Mapping a toggle button  (Read 103 times)
zeroalpha_nz
New Member
*



MIDI-OX Rules!

   


Posts: 2
Mapping a toggle button
« on: Sep 8th, 2024, 1:35am »
Quote Quote Modify Modify

Sorry I've just finished searching and not been able to find a solution.
 
I need to find a way to have a button press toggle, press once to mute the channel in my DAW, press again to unmute. I'm working in Studio One and a Numark DJ controller. At the moment it turns off soon as I release it.
 
I understand how to use the Translation map as I've just converted the buttons from note on/off to CC. Is there a way to set up a toggle function? Thanks
IP Logged
Breath
Administrator
*****





   
WWW

Gender: male
Posts: 1014
Re: Mapping a toggle button
« Reply #1 on: Sep 8th, 2024, 4:45am »
Quote Quote Modify Modify

Hi
To toggle anything (sending the SAME message to do a DIFFERENT job) you need to know the current state of the switch so you can make a decision on which result should occur.
 
What you need to turn a switch on and off (or increment and decrement) is the ability for the program to remember what messages you have already sent.
 
As an example...
CC7 is a continuous control for volume usually ( but it can be used for whatever the synth designer wants, but most choose Cc7 = volume)
CC7 0 usually sets the volume to 0 = Off.
 
You want a toggle mute switch.
So in this example you send CC7 0 and that turns the volume off  
That works. CC7 0 make the volume = 0.
 
Send it again - same result... it is still off
MidiOx doesn't know you want a different result, because it doesn't remember the previous messages.  
It just passes MIDI messages on or modifies them, or deletes them.
 
The designer of MidiOx has included a function where you can program the Midi messages and store the values in the code. So you can do it in the Script area (look it up in the Help)
 
There is a script example of mine that uses MS Jscript to remember the last state the switch was in (On or Off) and reverses it when it receives the message again (toggle switch).  
It should be a fairly simple thing to change a copy of that working code and make it do what you need.
 
The example is here  
http://www.midiox.com/cgi-bin/yabb/YaBB.pl?board=MOXScript;action=displa y;num=1657511134;start=0#0
 
I hope that helps
Royce
« Last Edit: Sep 8th, 2024, 4:48am by Breath » IP Logged
zeroalpha_nz
New Member
*



MIDI-OX Rules!

   


Posts: 2
Re: Mapping a toggle button
« Reply #2 on: Sep 8th, 2024, 5:44am »
Quote Quote Modify Modify

Hi Royce, thank you for the fast reply. Just a couple of questions.
 
If I use the script, do I not have to use the translation map to convert the note on/off to CC? Currently the buttons on my midi controller are sending note on/off
 
The first button I'm wanting to set to toggle is currently C 1 on ch6, will I need to adjust the script to do that and is this the line I need to edit?
 
// what message do we ant to change ?
   if (statraw == 0x90 && dat1 == 60 && dat2 > 0)   // NoteOn Middle C (NoteOn velocity 0 is really NoteOff)
 
would I change "60" to the note number of C 1?
IP Logged
Breath
Administrator
*****





   
WWW

Gender: male
Posts: 1014
Re: Mapping a toggle button
« Reply #3 on: Sep 8th, 2024, 8:42pm »
Quote Quote Modify Modify

Hi
"If I use the script, do I not have to use the translation map to convert the note on/off to CC?  
Currently the buttons on my midi controller are sending note on/off "
 
Any Midi message can be used.  
As it is a toggle switch you are building you really only need to detect one message.
 
OK...  I'm using Hexadecimal - in the js script, for hex, you will use "0x' then the number eg 0x90 is Note on message for channel 1
So  
0x = this is a hex number  
9  = NoteOn message
0  = channel (always 1 less than the 'musicians' channel value) ie channel is 0x0 to 0xF (0 to 15 decimal or 1 to 16 in normal Midi)
Middle C can have various values C3 or C4 being the more common. C4 is the default in MidiOx although it can be changed.
 
C1 is Key 18  (24 decimal) in the standard setup of MidiOx.
 
C1 can vary depending on the designers preference.
Press your C1 Key just to make sure what it is and Note down the number in MidiOx.
In the script you will be using that number.  
 
There are multiple ways to trigger it from the keyboard.
NoteOn - hit it and forget... use 0x9c where c = (channel -1)        
 
or you could hold down the note and release it at the right moment to trigger the event.  
The safer version for live performance as you have already selected the key.
 
Remember there are two different Note Off messages...
You can use 0x8c  with the Key and the Off Velocity
The other type of Key Off message (often used by Yamaha) is to use 0x9c (note on) then Key then 0x00 as the velocity.
 
Back to note on... Raw Note On to be changed
   if (statraw == 0x90 && dat1 == 0x18  && dat2 > 0)   // NoteOn is C 1 and  as NoteOn velocity 0 is really NoteOff so you don't want that)
 
if you want to work in decimal just leave the '0x' out.  24 instead of 0x18
 
Hope that helps
Royce
« Last Edit: Sep 11th, 2024, 8:11pm by Breath » IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »


MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.