Play/Stop audio on key press/release

I’m a music major taking a course on audio implementation using UE4, and we learn just about nothing in terms of coding and blue prints. Any help would be much appreciated!

You could add a audio component manually or spawn one.

If you use a created one with the add component (top left) you just drag and drop it in as a get node and than use it as target on your stop node. There is also a play node with a target.
(note. when you click on the audio component you have to insert your audio cue (file))

When you spawn it just promote it to a variable and than use get node of that variable and the Stop/play node.

(I can post some screenshots how it would look like and make some markers on it if needed)

Awesome, Thanks so much! Do you know if there is a way to make it so that as long as I’m holding down the key the attached sound will loop until released? When I loop the sound file itself, it doesn’t seem to terminate the loop

yeah sure just create a boolean variable “isPressed” for example and set it true when you hold a button or on input pressed set it false on Release.

You can then check if the variable on tick for example and if true use the play node for play again. (Image below)
Still, use stop on Release and later you may want to change it so it will not be checked every frame

(make sure your audio is not looping anymore)

Some images

On the Sound field on the right, you can fill in your file. Which you use on the Play Sound 2d

Can’t seem to find the “ispressed” condition

And how do I set it to “audio component” vs Synth or Media component

Can you explain what you mean? Did the image help you?

You can’t loop references backwards for one, only execution wires I think.