Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- #######################################
- # _ ____ #
- # / | | _ \ _ _ _ __ ___ _ __ #
- # | | | | | | | | | '_ ` _ \| '_ \ #
- # | |_ | |_| | |_| | | | | | | |_) | #
- # |_(_) |____/ \__,_|_| |_| |_| .__/ #
- # |_| #
- #######################################
- # Watch output from Korg on commandline:
- # aseqdump -p 24:1 | grep -v Clock
- # This script assumes that the Midi client is No. 24 and the port is 1.
- clear
- echo -e "This script shows the settings that produce the sound that you are *currently* hearing.
- Those settings (the \"patch\") might NOT be what you actually see on your Korg! If you've loaded a Program (and you've turned some knobs) then there is no way of knowing if what you see on the Korg are actually the settings that generate the sound you hear.
- On the Korg press/turn the following buttons/knobs:
- 1. Press Edit Mode
- 2. Press No. 12 on the sequencer
- 3. Turn the Program knob
- 4. Press Write
- When the message \"Transmitting\" has disappeared from the Monologue's display press CTRL + C on this computer.
- "
- # Copy the Korg's dump to a file and remove uncecessary stuff from it.
- # Starting to dump stuff to text file:
- aseqdump -p 24:1 > aseqdumpfile.txt
- # Removing all lines containing "Clock" etc.
- sed -i '/Clock\|Start\|Stop\|Note\|Control/d' aseqdumpfile.txt
- # Delete certian parts to only leave the HEX numbers:
- sed -i 's/ 24:1 System exclusive \|Waiting for data. Press Ctrl+C to end.\|Source Event Ch Data//g' aseqdumpfile.txt
- # Remove empty lines that were left behind:
- sed -i '/^$/d' aseqdumpfile.txt
- # Check if file is non-empty
- if [ -s aseqdumpfile.txt ]
- then
- echo "SysEx dumpfile exists and is non-empty"
- else
- echo -e "\e[31;5;1m \nSysEx dumpfile is empty. Is your Korg connected to this computer? Exiting...\n \e[0m"; exit
- fi
- #######################################################
- # ____ _ _ #
- # |___ \ | | | | _____ __ ___ ___ _ ____ __ #
- # __) | | |_| |/ _ \ \/ / / __/ _ \| '_ \ \ / / #
- # / __/ _ | _ | __/> < | (_| (_) | | | \ V / #
- # |_____(_) |_| |_|\___/_/\_\ \___\___/|_| |_|\_(_) #
- # #
- #######################################################
- # Converting numbers via functions.
- # The Korg sends a HEX number between 0 and 127 (Midi!) that represents the amount of which a knob is turned. However, if a knob is turned more than half way this number represents the amount of which it is turned past 50%. So the number must be devided by 2 and it must be added to 64 if knob > 50%. Another number determines *if* the knob was turned more than 50%.
- # Convert from HEX to DEC and devide by 2:
- function abc ()
- {
- # NR==1 means first record or first line.
- hex=`awk 'NR==1{print $'$1'}' aseqdumpfile.txt`
- dec=`echo $(( 16#$hex / 2 ))`
- echo $dec
- }
- # Determine value in DEC of entry No. $1 in record:
- function xyz ()
- {
- # NR==1 means first record or first line.
- hex=`awk 'NR==1{print $'$1'}' aseqdumpfile.txt`
- dec=`echo $(( 16#$hex ))`
- echo $dec
- }
- # Convert hex value to a value between 0 and 1023 and devide by 2:
- function val ()
- {
- hex=`awk 'NR==1{print $'$1'}' aseqdumpfile.txt`
- dec=`echo $(( 16#$hex / 2 ))`
- val=`echo $(( ($dec + 1) * 100 / 127 * 1023 /100 ))`
- echo $val
- }
- # Convert the devided number to percentage and devide by 2:
- function perc ()
- {
- hex=`awk 'NR==1{print $'$1'}' aseqdumpfile.txt`
- # The "+ 1" below to get 100% instead of 99% when fully turned open.
- dec=`echo $(( 16#$hex / 2 ))`
- perc=`echo $(( ($dec + 1) * 100 / 127 ))`
- echo $perc
- }
- function knob_values_not_halfway ()
- {
- perc=$(( $(perc $knob) )) # This is the precentage of knob turned.
- val=$(( $(val $knob) )) # This is the Korg value.
- dec=$(( $(abc $knob) )) # This is the Midi value.
- }
- function knob_values_halfway ()
- {
- perc=$(( $(perc $knob) + 50 ))
- val=$(( $(val $knob) + 512 ))
- dec=$(( $(abc $knob) + 64 ))
- }
- # Knobs:
- # 28 VCO1 shape
- # 31 VCO1 mixervolume
- # 42 Drive
- # 44 VCO2 octave
- # 50 LFO: wave, mode and target
- ######################################
- # _____ ____ _ _ #
- # |___ / / ___|| |_ __ _ _ __| |_ #
- # |_ \ \___ \| __/ _` | '__| __| #
- # ___) | ___) | || (_| | | | |_ #
- # |____(_) |____/ \__\__,_|_| \__| #
- # #
- ######################################
- clear
- echo -e "TABLE 1. Settings in % of knob turned, value on the display (from 0 - 1023) and Midi values (0 - 127) of the various knobs and switches of the Korg Monologue. The values of the Intensity of the EG and the LFO are between 0 and +/-511 on the Korg's display and between 63 and 0 for Midi. If the intensity is negative then its Midi value is between 64 and 127.
- ______________________________________________________________________
- \e[1mKnob \t\t\t Value (%) \t Korg value \t Midi value \e[0m
- ______________________________________________________________________"
- ######################### 1. OVERDRIVE #########################################
- knob=42
- number=`echo $(xyz 40)`
- string01=(19 23 27 31 51 55 59 63 83 115)
- # If No. 40 element of { ... } then > 50%.
- # Notice that the < 50% value is always 2 lower.
- knob_values_not_halfway $knob
- if [[ ${string01[@]} =~ $number ]]; then for element in ${string01[@]}; do
- if [[ $element == $number ]]; then knob_values_halfway $knob; fi; done; fi
- echo -e "
- \e[4m1. OVERDRIVE\e[0m \t\t $perc \t\t $val \t\t $dec"
- ######################### 2. VCO 1 ##############################################
- echo -e "\n\e[4m2. VCO 1\e[0m"
- # 2a. VCO 1 WAVE FORM
- number01=`echo $(xyz 43)`
- number02=`echo $(xyz 40)`
- string01='17 19 25 27 40 49 51 57 81 83 89'
- # Numbers 40 and 43 determine VCO 1 Wave.
- # Number 40 appears to be 2 lower than the no. 40 value in Drive.
- # If No. 43 greater than 63, then wave = triangular:
- # Value No. 40 is always 4 higher for the Sawtooth than for the Pulse wave.
- wave="Sawtooth |\|\| "
- if
- [ $number01 -gt 63 ]
- then
- wave="Triangular /\/\ "
- else
- if [[ ${string01[@]} =~ $number02 ]]; then for element in ${string01[@]}; do
- if [[ $element == $number02 ]]; then wave="Square |¯|_|"; fi; done; fi
- fi
- echo -e "\
- a. Wave form \t\t $wave"
- # 2b. VCO 1 SHAPE
- knob=28 # Knob 28 determines VCO 1 Shape.
- number=`echo $(xyz 24) / 8` # No. 24 determines if knob is > half way.
- # No. 43 might have someting to do w/ it too.
- # No. 24 must be devided by 8. If that number is odd then > 50%.
- # No. 24 depends on 'VCO1 Shape', 'VCO1 Mixer', 'VCO2 Shape' and'VCO2 Pitch'!
- if
- [ $((number%2)) -eq 0 ]
- then
- knob_values_not_halfway $knob
- else
- knob_values_halfway $knob
- fi
- echo -e "\
- b. Shape \t\t $perc \t\t $val \t\t $dec"
- # 2c. VCO 1 MIXER VOLUME
- knob=31
- # No. 24 must be greater than 64. If less, then knob not past half way.
- # No. 24 depends on 'VCO1 Shape', 'VCO1 Mixer', 'VCO2 Shape' and'VCO2 Pitch'!
- if
- [ $(xyz 24) -gt 63 ]
- then
- knob_values_halfway $knob
- else
- knob_values_not_halfway $knob
- fi
- echo -e "\
- c. Mixer volume \t $perc \t\t $val \t\t $dec"
- ################################# 3. VCO 2 #######################################
- echo -e "\n\e[4m3. VCO 2\e[0m"
- # 3a. VCO 2 WAVE FORM
- number01=`echo $(xyz 40)`
- number02=`echo $(xyz 44)`
- string01=(19 23 25 29 31 57 59 61 89 91 93)
- # [6-3-2017] Maybe 21 and 27 should be in there too. Making it 3 times 3 groups of uneven numbers.
- # Numbers 40 and 44 determine VCO 1 Wave.
- # If No. 40 element of { ... } then Sawtooth.
- # No. 40 changes w/ the 'VCO1 Wave' and 'EG Target' switches.
- # If No. 44 > 63, then wave = Triangular.
- # Else: Noise.
- wave="Noise \?^~- "
- if
- [ $number02 -gt 63 ]
- then
- wave="Triangular /\/\ "
- else
- if [[ ${string01[@]} =~ $number01 ]]; then for element in ${string01[@]}; do
- if [[ $element == $number01 ]]; then wave="Sawtooth |\|\| "; fi; done; fi
- fi
- echo -e "\
- a. Wave form \t\t $wave"
- # 3b.VCO 2 SHAPE
- knob=30 # Knob 30 determines VCO 2 Shape.
- number01=`echo $(xyz 24)` # Knob 24 determines if > or < 50%.
- string01=(4 20 68 72 76 84 88 92) # Shape < 50%.
- # No. 24 depends on 'VCO1 Shape', 'VCO1 Mixer', 'VCO2 Shape' and 'VCO2 Pitch'!
- # For > 50% the values are 32 higher
- # No. 44 seems to be associated too...
- knob_values_halfway $knob
- if [[ ${string01[@]} =~ $number01 ]]; then for element in ${string01[@]}; do
- if [[ $element == $number01 ]]; then
- knob_values_not_halfway $knob; fi; done; fi
- echo -e "b. Shape \t\t $perc \t\t $val \t\t $dec"
- # 3c. VCO 2 MIXER VOLUME
- knob=33
- # Knob 33 determines VCO 2 mixer level.
- # No. 32 must be even for knob 33 < 50%.
- if
- [ $(($(xyz 32)%2)) -eq 0 ]
- then
- knob_values_not_halfway $knob
- else
- knob_values_halfway $knob
- fi
- echo -e "\
- c. Mixer volume \t $perc \t\t $val \t\t $dec"
- # 3d. VCO 2 SYNC/RING
- switch=`echo $(xyz 45)` # Number 45 determines VCO2's Synch/Ring settings
- if
- [ $switch -eq 102 -o $switch -eq 106 ]
- then
- ring="Synch"
- else
- if
- [ $switch -eq 101 -o $switch -eq 105 ]
- then
- ring="Neutral"
- else
- ring="Ring"
- fi
- fi
- echo -e "\
- d. Synch/Ring \t\t $ring"
- # 3e. VCO 2 PITCH
- knob=29
- number01=`echo $(xyz 24)`
- string01=(18 20 52 60 84 92 116 124) # Pitch > 50%
- # VCO 2 Pitch is between -1200C and +1200C on the Korg's display!
- # Midi behaves normally.
- # If No. 24 element of { ... } then Pitch > 50%.
- # No. 24 depends on 'VCO1 Shape', 'VCO1 Mixer', 'VCO2 Shape' and 'VCO2 Pitch'!
- if [[ ${string01[@]} =~ $number01 ]]; then for element in ${string01[@]}; do
- if [[ $element == $number01 ]]; then
- temp_var01=1
- knob_values_halfway $knob
- # echo -e "Pitch \t\t\t $perc \t\t $(( ($perc - 50) * 24 ))C \t\t $dec"; fi; done; fi
- echo -e "c. Pitch \t\t $perc \t\t (not linear) \t $dec"; fi; done; fi
- if
- [ -z $temp_var01 ]
- then
- knob_values_not_halfway $knob
- # echo -e "Pitch \t\t\t $perc \t\t -$(( (50 - $perc) * 24 ))C \t $dec"
- echo -e "c. Pitch \t\t $perc \t\t (not lineair) \t $dec"
- fi
- # 3f. VCO 2 OCTAVE SWITCH
- switch01=`echo $(xyz 44)`
- if
- [[ $(xyz 44) -ge 0 && $(xyz 44) -lt 16 ]]
- then octave="4"
- elif
- [[ $(xyz 44) -ge 16 && $(xyz 44) -lt 32 ]]
- then octave="3"
- elif
- [[ $(xyz 44) -ge 32 && $(xyz 44) -lt 48 ]]
- then octave="2"
- elif
- [[ $(xyz 44) -ge 48 ]]
- then octave="1"
- fi
- echo -e "\
- f. Octave \t\t $octave"
- ############################### 4. FILTER ##########################################
- echo -e "\n\e[4m4. FILTER\e[0m"
- # 4a. FILTER CUTOFF
- knob=34
- number=`echo $(xyz 32)`
- string01=(34 35 38 39 42 43 47 48 50 51 55 58 62 63 98 99 102 103 110 111 114 126 127) # Knob > 50%
- # string01=(32 33 36 37 40 41 46 48 49 60 96 100 108 109 124 ) # Knob < 50%
- # Knob 32 determines > or < 50% Notice that the string is: two numbers that diifer 1, then + 4
- # then two more differing 1 and 4, etc. (sure???)
- # VCO2 mixer EG attack, EG decay, EG rate, EG intensity, Filter and Resonance all
- # influence knob 32's value too.
- # For < 50% add 2.
- knob_values_not_halfway $knob
- if [[ ${string01[@]} =~ $number ]]; then for element in ${string01[@]}; do
- if [[ $element == $number ]]; then knob_values_halfway $knob; fi; done; fi
- echo -e "\
- a. Cutoff \t\t $perc \t\t $val \t\t $dec"
- # 4b. FILTER RESONANCE
- knob=35
- number=`echo $(xyz 32)`
- string01=(32 33 34 37 39 49 51 53 97 98 99 109 114) # < 50%
- # VCO2 mixer EG attack, EG decay, EG rate, EG intensity, Filter and Resonance all
- # influence knob 32's value too (so 13 elements in string01?).
- # For > 50% add 4.
- knob_values_halfway $knob
- if [[ ${string01[@]} =~ $number ]]; then for element in ${string01[@]}; do
- if [[ $element == $number ]]; then knob_values_not_halfway $knob; fi; done; fi
- echo -e "\
- b. Resonance \t\t $perc \t\t $val \t\t $dec"
- ################## 5. ENVELOPE GENERATOR #########################################
- echo -e "\n\e[4m5. ENVELOPE GENERATOR\e[0m"
- # 5a. EG TYPE
- switch=`echo $(xyz 47)`
- # string01=(2 6 10 14 18 26 30 34 38 46 50 54 62 66 82 86 90 102) # Attack/release
- # string02=(1 5 9 13 17 25 29 33 37 45 49 53 61 65 81 85 89 101) # Attack/sustain/release
- # string03=(0 4 8 12 16 24 28 32 36 44 48 52 60 64 80 84 88 100) # Gate & attack/decay
- # It might be so that the difference between two values in a string is 4. What
- # about 22, 42, 58 and ... in string01?
- # String 1 to 3 differ 1 each time.
- if
- [ $(( $switch % 4 )) -eq 2 ]
- then
- type="Attack/release /\ "
- fi
- if
- [ $(( $switch % 4 )) -eq 1 ]
- then
- type="Attack/sustain/release /¯¯\ "
- fi
- if
- [ $(( $switch % 4 )) -eq 0 ]
- then
- type="Gate & attack/decay |¯/\¯¯| "
- fi
- if
- [ -z "$type" ]
- then type="Error in EG Type"
- fi
- echo -e "\
- a. Type \t\t $type"
- # 5b. EG ATTACK
- knob=36
- number=`echo $(xyz 32)` # Determines if knob 36 was turned > 50% or not.
- string01=(32 40 41 42 43 45 47 59 60 61 107 122 125 127) # > 50%
- # String02 is 8 lower than string01.
- knob_values_not_halfway $knob
- if [[ ${string01[@]} =~ $number ]]; then for element in ${string01[@]}; do
- if [[ $element == $number ]]; then knob_values_halfway $knob; fi; done; fi
- echo -e "\
- b. Attack \t\t $perc \t\t $val \t\t $dec"
- # 5c. EG DECAY
- knob=37
- number=`echo $(xyz 32)`
- string01=(27 48 49 50 51 52 53 55 58 59 61 115 116 125 127) # > 50%
- # String02 is 16 lower than string01.
- knob_values_not_halfway $knob
- if [[ ${string01[@]} =~ $number ]]; then for element in ${string01[@]}; do
- if [[ $element == $number ]]; then knob_values_halfway $knob; fi; done; fi
- echo -e "\
- c. Decay \t\t $perc \t\t $val \t\t $dec"
- # 5d. EG INTENSITY
- knob=38
- switch=`echo $(xyz 32)` # No. 32 in the Record is the +/- switch.
- string01=(32 34 36 37 39 42 45 50 52 53 59 61 98 99 104 109 114 120 122 124 125 126 127) # INT is +
- # string02=(0 2 4 5 7 10 13 18 20 27 29 66 67 72 77 82 88 90 92 93 94 95 ) # INT is -
- # String01 and 02 differ 32.
- # If INT is + then string01 32 - 63 OR 96 - 127 ???
- # If INT is - then string02 00 - 31 OR 64 - 95 ????
- # The intensity is between 0 and 511 on the Korg's display!
- # If INT = negative then INT inverses to 100% to 0%!
- # Positive EG Int is between 64 and 127 in Midi.
- # Negative EG Int is between 64 and 0 in Midi.
- knob_values_not_halfway $knob
- EG_intensity="-$((100 - $perc*2)) \t\t -$((511 - $val )) \t\t $(( 64 - $dec))"
- if [[ $(xyz 32) -gt 31 && $(xyz 32) -lt 64 ]]
- then
- EG_intensity="+$(($perc*2)) \t\t +$val \t\t $(( 64 + $dec ))"
- elif [[ $(xyz 32) -gt 95 ]]
- then
- EG_intensity="+$(($perc*2)) \t\t +$val \t\t $(( 64 + $dec ))"
- fi
- # If $EG_intensity is null then error etc.
- echo -e "\
- d. Intensity \t\t $EG_intensity"
- # 5e. EG TARGET
- switch01=`echo $(xyz 40)`
- switch02=`echo $(xyz 47)`
- if
- [ $switch01 -gt 80 ]; then target="Pitch" ; else if
- [ $switch02 -gt 63 ]; then target="Pitch 2"; else
- target="Cutoff" ; fi
- fi
- echo -e "\
- e. Target \t\t $target"
- ########################## 6. LFO ###############################################
- echo -e "\n\e[4m6. LFO\e[0m"
- # 6a. LFO WAVE
- switch=`echo $(xyz 50)` # Entry No. 50 in Record is LFO Wave form
- #string01=(2 6 10 18 22 26 34 38 42 66 70 74) # Sawtooth
- #string02=(1 5 9 17 21 25 33 37 41 65 69 73) # Triangular
- #string03=(0 4 8 16 20 24 32 36 40 64 68 72) # Square
- # Differs 1 from string to string.
- # If No. 50 multiple of 4 mod 0 then square, mod 1 = tri, mod 2 = saw. See '5a. EG type' for algorhytm.
- if
- [ $(( $switch % 4 )) -eq 0 ]
- then
- lfo_wave="Square |¯|_| "
- fi
- if
- [ $(( $switch % 4 )) -eq 1 ]
- then
- lfo_wave="Triangular /\/\ "
- fi
- if
- [ $(( $switch % 4 )) -eq 2 ]
- then
- lfo_wave="Sawtooth |\|\| "
- fi
- if
- [ -z "$lfo_wave" ]
- then lfo_wave="Error in LFO wave type"
- fi
- echo -e "\
- a. Wave \t\t $lfo_wave"
- # 6b. LFO MODE
- switch=`echo $(xyz 50)`
- string01=(8 9 10 24 25 26 40 41 42 72 73 74) # Fast
- string02=(4 5 6 20 21 22 36 37 38 68 69 70) # Slow
- string03=(0 1 2 16 17 18 32 33 34 64 65 66) # 1-Shot
- # Differs 4 from string to string.
- # If No. 50 is a multiple of 16 plus 0, 1 or 2 then one-shot.
- # In an "if then" condition "-o" means: "or".
- if
- [ $(($switch % 16)) -eq 0 -o $(($switch % 16)) -eq 1 -o $(($switch % 16)) -eq 2 ]
- then
- mode="One shot"
- fi
- if
- [ $(($switch % 16)) -eq 4 -o $(($switch % 16)) -eq 5 -o $(($switch % 16)) -eq 6 ]
- then
- mode="Slow"
- fi
- if
- [ $(($switch % 16)) -eq 8 -o $(($switch % 16)) -eq 9 -o $(($switch % 16)) -eq 10 ]
- then
- mode="Fast"
- fi
- if
- [ -z "$mode" ]
- then mode="Error in LFO mode type"
- fi
- echo -e "\
- b. Mode \t\t $mode"
- # 6c. LFO Rate
- knob=39
- number=`echo $(xyz 32)`
- if
- [[ $number -gt 63 ]]
- then
- knob_values_halfway $knob
- else
- if
- [[ $number -lt 64 ]]
- then
- knob_values_not_halfway $knob
- else
- echo -e "\n\t Error in LFO Rate"
- fi
- fi
- echo -e "\
- c. Rate \t\t $perc \t\t $val \t\t $dec"
- # 6d. LFO INT
- # The intensity is between 0 and 511 on the Korg's display!
- # Positive EG Int is between 64 and 127 in Midi.
- # Negative EG Int is between 0 and 64 in Midi.
- knob=41
- knob02=`echo $(xyz 40)` # Determines if INT is + or -
- # string01=(17 19 21 25 27 29 31 53 61 81 83 85 87 89 93 95 113 117) # INT is +
- # string02 is 1 lower?
- # If knob02 uneven then INT is +?
- knob_values_not_halfway $knob
- sign="-"
- midi="64 -"
- value01="100 -"
- value02="511 -"
- if [ $(($(xyz 40)%2)) -eq 1 ]
- then
- knob_values_not_halfway $knob
- sign="+"
- midi="64 +"
- value01=""
- value02=""
- fi
- echo -e "d. Intensity \t\t $sign$(($value01 $perc*2)) \t\t $sign$(($value02 $val)) \t\t $(($midi $dec))"
- # 6e. LFO TARGET
- switch=`echo $(xyz 50)` # Entry No. 50 in Record is "Target"
- string01=(32 33 34 36 37 38 40 41 42 98) # Pitch
- string02=(16 17 18 20 21 22 24 25 26 82) # Shape
- string03=(0 1 2 4 5 6 8 9 10 66) # Cutoff
- # Differs 16 from string to string.
- # ? If switch is multiple of 64 plus a number between 0 and 15 then lfo_target = cutoff?
- for i in {0..15}; do
- if
- [ $(($switch % 64 )) -eq $i ]
- then
- lfo_target="Cutoff"
- fi
- done
- for i in {16..31}; do
- if
- [ $(($switch % 64 )) -eq $i ]
- then
- lfo_target="Shape"
- fi
- done
- for i in {32..47}; do
- if
- [ $(($switch % 64 )) -eq $i ]
- then
- lfo_target="Pitch"
- fi
- done
- if
- [ -z "$lfo_target" ]
- then lfo_target="Error in LFO target type"
- fi
- echo -e "\
- e. Target \t\t $lfo_target"
- echo "______________________________________________________________________"
Add Comment
Please, Sign In to add comment