A small note on the sound project on Unity (Survival Shooter) through the audio programming language Chuck and Open Sound Control (OSC) .
As a result of all the manipulations, this is the result:
All sounds are generated on the fly in Chuck. Wav files are not used at all. To generate a similarity of voice, a solution written by Perry Cook for Chuck was used, the essence of the decision is partially explained in the course on Physics-Based Sound Synthesis for Games and Interactive Systems . An ordinary sawtooth wave with a “falling” pitch and addition of a chorus effect is used as a shot.
To send the OSC messages, Mike Heavers' practices are used . They need to be imported into the Unity-project: Osc.cs plugin, UDPPacketIO.cs plugin, OSCTestSender.cs script. For each object that makes a sound, we attach these plugins and a revised script - for each it has its own, the addresses of the OSC messages change.
There are 9 sound sources in the project:
Accepting OSC messages in Chuck is done using the OscIn class. Specify the corresponding port (oin.port) and address (oin.addAddress). Further, when an osc-message is received, a sound is generated.
On the side of Chuck, there are 5 separate projects, each of which receives a message in its own port and generates the corresponding sound (s):
For the test, you must first run all Chuck programs - we make a separate init.ck startup file. Then we start the Unity project. Playing, OSC messages are generated as soon as the desired event occurs, Chuck receives messages and generates sound.
This can be visualized by the scheme:
The only problem I encountered was switching the OSC port to another mob. If many characters are spawned, for example, 3 zombie bunnies, 2 zombie bears, then the sound will be played only in the first spawned mob of the corresponding type. Channel switching will occur only after killing this first mob. I have not found a quick solution yet.
I hope it was interesting if someone has interesting links on these topics (OSC, sound generation, etc.) - please share in the comments.
Thanks for attention!
Source: https://habr.com/ru/post/319524/
All Articles