informa
/
2 MIN READ
Blogs

Generating audio for Unity-projects with Chuck and OSC

Short note about generating audio for Unity (Survival Shooter) with Chuck audio-programming language and Open Sound Control (OSC).

Short note about generating audio for Unity (Survival Shooter) with Chuck audio-programming language and Open Sound Control (OSC). After all we will get this result:

All sound generates on the fly in Chuck. Wav-files is not used at all. For voice generation I use Perry Cook’s solution which is explained in his Physics-Based Sound Synthesis for Games and Interactive Systems course. For shooting I use simple sawtooth oscillator with falling pitch and a little bit of chorus.

How it works

For sending OSC-messages I use solutions from Mike Heavers. They must be imported in the Unity project: Osc.cs plugin, UDPPacketIO.cs plugin, OSCTestSender.cs script. Connect this plugins and modified script to every game object which produce sound. OSCTestSender.cs needs to be modified for every game object to specify unique OSC-address.

We have 9 sound events in game:

  • Player Shoot
  • Player Hurt
  • Player Death
  • Zombunny Hurt (small green mob)
  • Zombunny Death
  • Zombear Hurt (small red mob)
  • Zombear Death
  • Hellephant Hurt (big yellow mob)
  • Hellephant Death

To receive OSC-messages in Chuck you must use OscIn class. Write down the port (oin.port) and address (oin.addAddress). Programm the sound effect that needs to be triggered by this message.

On the Chuck side there are 5 projects:

  • oscin_shoot
  • oscin_player_hurt
  • oscin_zombunny_hurt
  • oscin_zombear_hurt
  • oscin_hellephant_hurt

For testing, you must run all Chuck scripts first. This can be done via init.ck solution which launches all 5 projects at the same time. Then start Unity project. Play the game, OSC-messages will be generated and sent to Chuck. Then Chuck will generate appropriate sound effects.

The whole process can be demonstrated on the scheme:

The only issue I don't know how to beat is the spawn of multiple targets of the same type (for example 3 bunnies and 4 bears). The OSC-port is stick to the first enemy of particular type (first bunny and first bear) and will switch to new enemy only after mob will be killed.

Hope you enjoy the result, and if you have some links regarding OSC or sound generation - please share them in comments.

Thanks!
Petr

Latest Jobs

Cryptic Studios

Remote
1.19.23
Senior Producer

Night School Studio

Los Angeles, CA, USA
1.09.23
Level Designer / Scripter, Games Studio

Fast Travel Games

Hybrid (Stockholm, Sweden)
1.09.23
Social Media / Community Manager
More Jobs   

CONNECT WITH US

Explore the
Subscribe to
Follow us

Game Developer Job Board

Game Developer Newsletter

@gamedevdotcom

Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Browse
Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Subscribe
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more