Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A WAAPI library in C#.

NotificationsYou must be signed in to change notification settings

johnloser-lwi/WwiseTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuget

Wwise Tools

Wwise productivity tools based on C# Waapi under development, enabling rapid generation and editing of Wwise objects to achieve batch addition effects, improving work efficiency.

Author: Yang Weiqin (AKA John Loser)


Compatibility Note

Currently, WwiseTools have been applied in projects of versions 2019.1, 2019.2, and 2021.1, but not all functions have been fully tested for compatibility with these versions.
Adjustments have been made to existing interfaces according toWwise 2022.1 Important Migration Notes, and most functions are available in Wwise 2022.

Instructions for Use

Project Configuration

Find WwiseTools on NuGet and add to your project.

Importing a Single Audio File

// All non-asynchronous functions will be gradually removed, please use asynchronous execution functions as much as possiblestaticasyncTaskMain(string[]args){awaitWwiseUtility.Instance.ConnectAsync();// First initialize the Wwise project connection (optional).varobj=awaitWwiseUtility.Instance.ImportSoundAsync(@"audio file path");// Import the specified audio file, returning a "WwiseObject".Console.WriteLine(obj.ToString());// Display information about the added object.awaitWwiseUtility.Instance.DisconnectAsync();// Close the Wwise project connection.}

After running the program, the Wwise project will import the specified file as a Sound, with the default path being "\Actor-Mixer Hierarchy\Default Work Unit", and the console will output the name, ID, and type information of the added object.

Creating and Moving Objects

vartestFolder=awaitWwiseUtility.Instance.CreateObjectAtPathAsync("TestFolder",WwiseObject.ObjectType.Folder);// Create a folder named "TestFolder", with the default path being "\Actor-Mixer Hierarchy\Default Work Unit".vartestSound=awaitWwiseUtility.Instance.CreateObjectAtPathAsync("TestSound",WwiseObject.ObjectType.Sound);// Create a sound object named "TestSound", with the default path being "\Actor-Mixer Hierarchy\Default Work Unit".awaittestFolder.AsContainer().AddChildAsync(testSound);// Move "testSound" under "testFolder".

After running the program, there will be a folder named "TestFolder" in the Wwise project, containing a sound object named "TestSound".

Generating Events

Continuing from the previous example, we can create a play event for "testSound".

awaitWwiseUtility.Instance.CreatePlayEventAsync("TestEvent",awaittestSound.GetPathAsync());// Create an event named "TestEvent" to play "testSound", with the default path being "\Events\Default Work Unit".

After running the program, there will be an event named "TestEvent" in the Wwise project, with the "Play Action" containing a reference to "TestSound".


Setting Properties and References

Setting Attenuation Reference

varrandomContainer=awaitWwiseUtility.Instance.CreateObjectAtPathAsync("TestRandomContainer",WwiseObject.ObjectType.RandomSequenceContainer);// Create a RandomContainer named "TestRandomContainer", stored in "randomContainer"./*Set the "Attenuation" reference of "randomContainer" to "TestAttenuation",this function will automatically enable the "Attenuation" option,if "TestAttenuation" cannot be found, it will be created under "\Attenuations\Default Work Unit".*/awaitrandomContainer.AsVoice().SetAttenuationAsync("TestAttenuation");

After running the program, there will be a RandomContainer named "TestRandomContainer" in the Wwise project, with the "Attenuation" parameter checked in the "Positioning" menu and referenced to "TestAttenuation".

Manual Setting of Properties and References

In addition to the "SetAttenuation" function provided by "RandomContainer", we can also manually set properties and references to achieve the same functionality, while having greater flexibility. We can add an Attenuation named "TestAttenuation" to ShareSet/Attenuations/Default Work Unit in Wwise, then use the "WwiseUtility.Instance.SetObjectProperty" and "WwiseUtility.Instance.SetObjectReference" functions to set properties and references.

/*Get the Attenuation we created by name, stored in "attenuation", the name here must be in the format "type:name",where "type" is "Attenuation" and "name" is "TestAttenuation" in this example.*/varattenuation=awaitWwiseUtility.Instance.GetWwiseObjectByNameAsync("Attenuation:TestAttenuation");awaitWwiseUtility.Instance.SetObjectPropertyAsync(randomContainer,WwiseProperty.Prop_EnableAttenuation(true));// Enable "Attenuation".awaitWwiseUtility.Instance.SetObjectReferenceAsync(randomContainer,WwiseReference.Ref_Attenuation(attenuation));// Add reference "attenuation" to "randomContainer".

After running the program, the same effect as the previous example will be achieved.

Custom Property and Reference Content

Although the current "WwiseProperty" and "WwiseReference" classes already include most of the properties and references' static creation functions, sometimes we still need to manually set the content of properties and references.

varrandomContainer=awaitWwiseFactory.CreateRandomSequenceContainer("TestRandomContainer",true,awaitWwiseUtility.Instance.GetWwiseObjectByPathAsync("\\Actor-Mixer Hierarchy\\Default Work Unit"));// Create a RandomContainer named "TestRandomContainer".vartestProperty=newWwiseProperty("EnableAttenuation",true);// Create a property object, property name is "EnableAttenuation", value is "true".varattenuation=awaitWwiseUtility.Instance.GetWwiseObjectByNameAsync("Attenuation:TestAttenuation");// Get the "Attenuation" named "TestAttenuation" from the Wwise projectvartestReference=WwiseReference.Ref_Attenuation(attenuation);// Create a reference object, reference "attenuation".awaitWwiseUtility.Instance.SetObjectPropertyAsync(randomContainer,testProperty);// Set property "testProperty" for "randomContainer".awaitWwiseUtility.Instance.SetObjectReferenceAsync(randomContainer,testReference);// Add reference "testReference" to "randomContainer".

After running the program, the same effect as the previous example will be achieved. Of course, we can also set other properties and references, and you can find more information about properties and reference parameters inWwise Objects Reference.

Directly Modifying WWU Files

Currently, some functions cannot be directly implemented through Waapi, such as setting "Playlist" in "Sequence Container". In this case, we need a specific solution to directly modify WWU files. WWU files are XML files. In the current version, we can use "WwiseWorkUnitParser"

to read and set parameters. We take setting "Playlist" in "Sequence Container" as an example (this function has been written into "SetPlaylist" function of "WwiseSequenceContainer").

staticasyncTaskMain(string[]args){WwiseObjectcontainer=awaitWwiseUtility.Instance.CreateObjectAtPathAsync("TestContainer",WwiseObject.ObjectType.RandomSequenceContainer);// Create a Sequence ContainerWwiseObjectsound=awaitWwiseUtility.Instance.CreateObjectAtPathAsync("TestSound",WwiseObject.ObjectType.Sound,awaitcontainer.GetPathAsync());// Create an empty soundawaitWwiseUtility.Instance.SaveWwiseProjectAsync();// Save the projectWwiseWorkUnitParserparser=newWwiseWorkUnitParser(awaitWwiseUtility.Instance.GetWorkUnitFilePathAsync(container));// Create WwiseWorkUnitParser and get the WorkUnit file of container// Get the Playlist node of containervarxpath="//*[@ID='"+container.ID+"']/Playlist";varplaylistNode=parser.XML.SelectSingleNode(xpath);// Get the corresponding XML node of containervarcontainerNode=parser.GetNodeByID(container.ID);// Clear the existing Playlistif(playlistNode!=null){containerNode.RemoveChild(playlistNode);parser.SaveFile();}varnew_playlist=parser.XML.CreateElement("Playlist");varnode=parser.XML.CreateElement("ItemRef");node.SetAttribute("Name",sound.Name);node.SetAttribute("ID",sound.ID);new_playlist.AppendChild(node);containerNode.AppendChild(parser.XML.ImportNode(new_playlist,true));parser.SaveFile();awaitWwiseUtility.Instance.ReloadWwiseProjectAsync();// To make the modification effective and avoid errors, the project needs to be reloadedawaitWwiseUtility.Instance.DisconnectAsync();}

After running the program, there will be a SequenceContainer named "TestContainer" in the project, containing an empty sound named "TestSound", and the Playlist of "TestContainer" will contain "TestSound".

About

A WAAPI library in C#.

Resources

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp