Audiosurf 2

Audiosurf 2

Nexie's Guitar Hero single block
Shinken 10 Oct, 2016 @ 4:08pm
FreePIE Strumming Script: Hammer-On Edition
I've completed the next piece to complete Guitar Hero simulation: Hammer-Ons (Tapping) are now part of the script! If you keep the strum bar/key pressed you're in Hammer-On mode where you can do tapping instead of strumming.

You can't tap multiple consecutive notes on the same lane though - that would be cheating :-P

I also found a much better layout for the keyboard version with less key-matrix-blocking and added lot's of commentary as well as an easy way to configure keyboard or controller at the start of the script including a tutorial text. No Python-language knowledge needed!

Without further ado, here's the code. Just copy-past into FreePIE!

Keyboard Version
Pastebin link (easier to read and copy) http://pastebin.com/wdYyGUFK
# THIS SCRIPT SHOULD BE USED WITH FREEPIE # http://andersmalmgren.github.io/FreePIE/ #------------------------------------------------------------------------------ # Key-Config: # Use Digital Genesis' Keyscan # ( ftp:/ftp.digitalgenesis.com/pub/keyscan/keyscan09.zip ) to find: # Five adjactend keys on your keyboard of which: # Key 1-4 and key 2-5 and any other combo of 4 keys can be pressed simultanously, # plus an easy to spam strumming bar key, that can also be pressed simultanously # additionally to the other 4 keys. # # The keys also can't be the predefiened keys "1,2,3,4,5" or "a,s,d,f,g" or # "e,r,space,u,i" because the game already uses those. # Of course some keys like ESC are also a bad idea to use. # # On my keyboard I've found the best result with "RightShift, Slash, Period, Comma, M" # plus "LeftControl" as Strumbar, while holding the keyboard away from your body with # the cable pointing towards your head # (so your right thumb easily reaches LeftControl). # It's the default you find below. # If you have an expensive "N-Key Rollover" keyboard you're in luck and can use # whatever you want (except predefined keys)! # # If you found your keys insert them below. Use Key."XXX" and autocomplete to find the # correct key name FreePIE wants or look up key names under # https://github.com/AndersMalmgren/FreePIE/wiki/Reference under the "Key" section. # For example: Non-Numpad numbers are "D1 - D0". Numpad numbers are "NumberPad0 to # NumberPad9". #------------------------------------------------------------------------------------ Key1 = "RightShift" Key2 = "Slash" Key3 = "Period" Key4 = "Comma" Key5 = "M" Strumbar = "LeftControl" Test = Key.M # !!!script code starts from here!!! #------------------------------------------------- # declare some cycle-persisting variables at start: #------------------------------------------------- if starting: BarIsPressed = 0 ButtonIsPressed=[0,0,0,0,0] LastHOPOButton = 5 # If LastHOPOButton equals 5, no button has been pressed in a HOPO-mode Session #------------------------------------------------------------------------- # check for not pressed, pressed and recently pressed stuff #------------------------------------------------------------------------- # check for not pressed buttons if keyboard.getKeyUp(getattr(Key, Key1)): ButtonIsPressed[0] = 0 if keyboard.getKeyUp(getattr(Key, Key2)): ButtonIsPressed[1] = 0 if keyboard.getKeyUp(getattr(Key, Key3)): ButtonIsPressed[2] = 0 if keyboard.getKeyUp(getattr(Key, Key4)): ButtonIsPressed[3] = 0 if keyboard.getKeyUp(getattr(Key, Key5)): ButtonIsPressed[4] = 0 # ButtonJustDown variable ButtonJustDown=[0,0,0,0,0] # check for currently pressed and possibly just pressed buttons if keyboard.getKeyDown(getattr(Key, Key1)): if ButtonIsPressed[0] == 0: ButtonJustDown[0] = 1 ButtonIsPressed[0] = 1 if keyboard.getKeyDown(getattr(Key, Key2)): if ButtonIsPressed[1] == 0: ButtonJustDown[1] = 1 ButtonIsPressed[1] = 1 if keyboard.getKeyDown(getattr(Key, Key3)): if ButtonIsPressed[2] == 0: ButtonJustDown[2] = 1 ButtonIsPressed[2] = 1 if keyboard.getKeyDown(getattr(Key, Key4)): if ButtonIsPressed[3] == 0: ButtonJustDown[3] = 1 ButtonIsPressed[3] = 1 if keyboard.getKeyDown(getattr(Key, Key5)): if ButtonIsPressed[4] == 0: ButtonJustDown[4] = 1 ButtonIsPressed[4] = 1 # check for not pressed strum bar and reset HOPO Session if true if keyboard.getKeyUp(getattr(Key, Strumbar)): BarIsPressed = 0 LastHOPOButton = 5 #------------------------------------------------------------------------------- # HOPO-mode: If the strum bar is pressed, check if a hammered button is different to # the last one and, if true, do the thing # No repeated same button Hammer-Ons allowed in this script, because of TRVENESS # (unless you press 1-5 :-D) #------------------------------------------------------------------------------- elif ButtonJustDown[4] and LastHOPOButton != 4: keyboard.setPressed(Key.D5) LastHOPOButton = 4 elif ButtonJustDown[3] and LastHOPOButton != 3: keyboard.setPressed(Key.D4) LastHOPOButton = 3 elif ButtonJustDown[2] and LastHOPOButton != 2: keyboard.setPressed(Key.D3) LastHOPOButton = 2 elif ButtonJustDown[1] and LastHOPOButton != 1: keyboard.setPressed(Key.D2) LastHOPOButton = 1 elif ButtonJustDown[0] and LastHOPOButton != 0: keyboard.setPressed(Key.D1) LastHOPOButton = 0 #------------------------------------------- # button handover in case of actual strumming #------------------------------------------- if BarIsPressed == 0 and keyboard.getKeyDown(getattr(Key, Strumbar)): BarIsPressed = 1 if ButtonIsPressed[4]: keyboard.setPressed(Key.D5) elif ButtonIsPressed[3]: keyboard.setPressed(Key.D4) elif ButtonIsPressed[2]: keyboard.setPressed(Key.D3) elif ButtonIsPressed[1]: keyboard.setPressed(Key.D2) elif ButtonIsPressed[0]: keyboard.setPressed(Key.D1)

Guitar Hero Controller Version
Pastebin link (easier to read and copy): http://pastebin.com/x03jJTm7
# THIS SCRIPT SHOULD BE USED WITH FREEPIE # http://andersmalmgren.github.io/FreePIE/ #-------------------------------------------------------------------------------------- # CONTROLLER-CONFIG: #-------------------------------------------------------------------------------------- # Unfortunately, when plugging Xbox/Playstation/Wii Guitar Hero Controllers into your # PC, chances are, that they don't really behave as they should. # To make it work with this script, some configuring needed. # The default config is for a GH X-plorer # (the one they sold for Xbox/PC with Guitar Hero [4] World Tour) # with no other controller plugged in. # So if you got one of those you're in luck. # # Let's go: Assuming you successfully installed the controller # (3rd party software may be needed), you need to get an overview. # Type "joy.cpl" in the Windows search bar and press enter to open your game controller # control panel. # If you have multiple controllers, you need to count down the list from the top # (1,2,3..) and use the number the GH controller is placed at in # "JoystickNumber = X" # # Go into the "properties", press your controller buttons and note which number is # flashing for each fret button. # If you're unlucky, from green to orange, this wont be 1,2,3,4,5 but 2,4,5,3,1 etc. # Enter the exact consecutive green to orange numbering you oberserved in # "Button1_Green = X" to "Button5_Orange = Z" # # At last we need to configure the strum bar. # Technically this is implemented as a "POV-hat". If it's not on your Controller # (and some axis is used instead) unfortunatelly you need to rewrite the # "joystick[x].pov[y] parts of the script and adept it for an axis but you can use # the same principle. # # The script needs the default (not pressed) value of the POV-hat to differenciate it # from the non-default value when it's pressed. # Start the script and observe the "Watch" tab. # Write the value you get when not pressing the bar into "DefaultBarValue = X". # # That's it! You configured your GH controller for this script! #------------------------------------------------------------------------------------ JoystickNumber = 1 Button1_Green = 1 Button2_Red = 2 Button3_Yellow = 4 Button4_Blue = 3 Button5_Orange = 5 DefaultBarValue = -1 # !!!script code starts from here!!! #--------------- # POV-Diagnostics #--------------- diagnostics.watch(joystick[0].pov[0]) if starting: #------------------------------------------------ # config-value-transformation #------------------------------------------------ j = JoystickNumber - 1 b1 = Button1_Green - 1 b2 = Button2_Red - 1 b3 = Button3_Yellow - 1 b4 = Button4_Blue - 1 b5 = Button5_Orange -1 p = DefaultBarValue #------------------------------------------------- # declare some cycle-persisting variables at start: #------------------------------------------------- BarIsPressed = 0 ButtonIsPressed=[0,0,0,0,0] LastHOPOButton = 5 # If LastHOPOButton equals 5, no button has been pressed in a HOPO-mode Session #---------------------------------------------------------------------- # check for not pressed, pressed and recently pressed stuff #---------------------------------------------------------------------- #check for not pressed buttons if joystick[j].getDown(b1) == 0: ButtonIsPressed[0] = 0 if joystick[j].getDown(b2) == 0: ButtonIsPressed[1] = 0 if joystick[j].getDown(b3) == 0: ButtonIsPressed[2] = 0 if joystick[j].getDown(b4) == 0: ButtonIsPressed[3] = 0 if joystick[j].getDown(b5) == 0: ButtonIsPressed[4] = 0 #ButtonJustDown variable ButtonJustDown=[0,0,0,0,0] #check for currently pressed and possibly just pressed buttons if joystick[j].getDown(b1): if ButtonIsPressed[0] == 0: ButtonJustDown[0] = 1 ButtonIsPressed[0] = 1 if joystick[j].getDown(b2): if ButtonIsPressed[1] == 0: ButtonJustDown[1] = 1 ButtonIsPressed[1] = 1 if joystick[j].getDown(b3): if ButtonIsPressed[2] == 0: ButtonJustDown[2] = 1 ButtonIsPressed[2] = 1 if joystick[j].getDown(b4): if ButtonIsPressed[3] == 0: ButtonJustDown[3] = 1 ButtonIsPressed[3] = 1 if joystick[j].getDown(b5): if ButtonIsPressed[4] == 0: ButtonJustDown[4] = 1 ButtonIsPressed[4] = 1 # check for not pressed strum bar and reset HOPO Session if true if joystick[j].pov[0] == p: BarIsPressed = 0 LastHOPOButton = 5 #---------------------------------------------------------------------------------- # HOPO-mode: If the strum bar is pressed, check if a hammered button is different to # the last one and, if true, do the thing # No repeated same button Hammer-Ons allowed in this script, because of TRVENESS # (unless you press 1-5 Number Keys :-D)! #---------------------------------------------------------------------------------- elif ButtonJustDown[4] and LastHOPOButton != 4: keyboard.setPressed(Key.D5) LastHOPOButton = 4 elif ButtonJustDown[3] and LastHOPOButton != 3: keyboard.setPressed(Key.D4) LastHOPOButton = 3 elif ButtonJustDown[2] and LastHOPOButton != 2: keyboard.setPressed(Key.D3) LastHOPOButton = 2 elif ButtonJustDown[1] and LastHOPOButton != 1: keyboard.setPressed(Key.D2) LastHOPOButton = 1 elif ButtonJustDown[0] and LastHOPOButton != 0: keyboard.setPressed(Key.D1) LastHOPOButton = 0 #------------------------------------------- # button handover in case of actual strumming #------------------------------------------- if BarIsPressed == 0 and joystick[j].pov[0] != p: BarIsPressed = 1 if ButtonIsPressed[4]: keyboard.setPressed(Key.D5) elif ButtonIsPressed[3]: keyboard.setPressed(Key.D4) elif ButtonIsPressed[2]: keyboard.setPressed(Key.D3) elif ButtonIsPressed[1]: keyboard.setPressed(Key.D2) elif ButtonIsPressed[0]: keyboard.setPressed(Key.D1)

The last missing part are "Pull-Offs". It's only a relativly small subset but part of the experience nontheless. Unfortunately I don't think I'll add that very soon because with pull-offs you're kinda opening Pandoras Box.

It's easy to accumulate exact negative edge data of button releases (it's just a reverse "ButtonJustDown" during the "not pressing buttons" check) but that's only a small part of the problem.

Far more importantly I need to eliminate accidental pull-offs while strumming which can happen more easily than you'd think in fast sections. Maybe it's enough to use a timer based on cycles for this but a system-time based timer would be more universal and fail-safe.

And last but not least I need to eliminate accidental pull-offs during hammer-on strings while still allowing to use pull-offs and hammer-ons consecutivly (for example for "trill" patterns).
To be honest - I have no idea yet how to achieve that. A timer wouln't be of any help in this case. Maybe it's best to leave that box closed.

Anyway have fun with the script :-D
Last edited by Shinken; 10 Oct, 2016 @ 4:46pm
< >
Showing 1-6 of 6 comments
thatbluflame 16 Jan, 2019 @ 7:32pm 
Thanks a ton man, i edited the mod this is for so its alot slower and plays alot like how guitar hero would. This script just made it complete. I have always dreamed of a procedurely generated guitar hero game and this. This just made my day. Thank you so much!
thatbluflame 16 Jan, 2019 @ 7:36pm 
i also have a guitar hero 5 controller. the red/white one and i only got into clone hero and stuff back in november 2018
Shinken 5 Apr, 2019 @ 1:52pm 
Originally posted by bluflame:
Thanks a ton man, i edited the mod this is for so its alot slower and plays alot like how guitar hero would. This script just made it complete. I have always dreamed of a procedurely generated guitar hero game and this. This just made my day. Thank you so much!
Hey! Can you share the edits you've made to make the single block mod slower? "Extreme" is ok for me in most cases but some songs are just way to much.
thatbluflame 5 Apr, 2019 @ 2:47pm 
Originally posted by Shinken:
Originally posted by bluflame:
Thanks a ton man, i edited the mod this is for so its alot slower and plays alot like how guitar hero would. This script just made it complete. I have always dreamed of a procedurely generated guitar hero game and this. This just made my day. Thank you so much!
Hey! Can you share the edits you've made to make the single block mod slower? "Extreme" is ok for me in most cases but some songs are just way to much.

https://drive.google.com/open?id=1WMfGydnP347ZKvU9QsVVanz-wCN7ThLm

here it is! just add it to the mods folder, then to the folder that contains the original mod and just replace that folder with this one and you should be good to go:steamhappy:
Shinken 5 Apr, 2019 @ 4:22pm 
Originally posted by bluflame:
Originally posted by Shinken:
Hey! Can you share the edits you've made to make the single block mod slower? "Extreme" is ok for me in most cases but some songs are just way to much.

https://drive.google.com/open?id=1WMfGydnP347ZKvU9QsVVanz-wCN7ThLm

here it is! just add it to the mods folder, then to the folder that contains the original mod and just replace that folder with this one and you should be good to go:steamhappy:
Awesome! Thank you! :lunar2019grinningpig::cozyspaceengineersc:
thatbluflame 5 Apr, 2019 @ 7:52pm 
Originally posted by Shinken:
Originally posted by bluflame:

https://drive.google.com/open?id=1WMfGydnP347ZKvU9QsVVanz-wCN7ThLm

here it is! just add it to the mods folder, then to the folder that contains the original mod and just replace that folder with this one and you should be good to go:steamhappy:
Awesome! Thank you! :lunar2019grinningpig::cozyspaceengineersc:

Your welcome!:2018salienpsychic:
< >
Showing 1-6 of 6 comments
Per page: 1530 50