def transportX(object_guid):
    try:
        with WaapiClient() as client:
            # Set the query parameter to the GUID of the controllable object of the transport
            transport_args = {"object": object_guid}

            # The return value is the transport object ID in dictionary format, such as {'transport': 12}
            result_transport_id = client.call("ak.wwise.core.transport.create",
                                              transport_args)

            # Set the conditions through 'object_guid' and get the object name through ʻak.wwise.core.object.get`. Of course, if you directly pass in the object name above to create a transport object, you can also omit this step
            args = {"from": {"id": [object_guid]}}

            opts = {"return": ["name"]}

            # Call 'ak.wwise.core.object.get' to get the object name in dictionary format, such as {'name':'MyObjectName'}
            result_dict_name = client.call("ak.wwise.core.object.get",
                                           args,
                                           options=opts)['return'][0]

            # Combine the two dictionaries of object name and transport object ID to obtain a transport strip session with a dictionary structure like {'name':'MyObjectName','transport': 1234}
            return result_dict_name.update(result_transport_id)

    except CannotConnectToWaapiException:
        print(
            "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
        )
 def test_large_rpc(self):
     with WaapiClient() as client:
         result = client.call("ak.wwise.core.object.get", {
             "from": {
                 "name": ["GameParameter:a" + str(n) for n in range(5000)],
             }
         })
         self.assertTrue(client.is_connected())
Ejemplo n.º 3
0
    def test_exception_on_unknown_uri(self):
        with WaapiClient(allow_exception=True) as client:
            try:
                client.call("i.dont.exist", someArg=True)
            except WaapiRequestFailed as e:
                self.assertEqual(e.kwargs.get("message"), "The procedure URI is unknown.")
                return

            self.fail("Should have thrown an exception")
Ejemplo n.º 4
0
    def test_exception_on_invalid_argument(self):
        with WaapiClient(allow_exception=True) as client:
            try:
                client.call("ak.wwise.core.getInfo", someArg=True)
            except WaapiRequestFailed as e:
                self.assertEqual(e.kwargs.get("details", {}).get("typeUri", ""), "ak.wwise.schema_validation_failed")
                return

            self.fail("Should have thrown an exception")
Ejemplo n.º 5
0
 def test_with_statement_cannot_connect(self):
     bad_address = "ws://bad_address/waapi"
     try:
         with WaapiClient(bad_address) as client:
             self.fail("Should not reach this part of the code")
     except CannotConnectToWaapiException as e:
         # Validate the message indicate the incorrect URL
         self.assertIn(bad_address, str(e))
     except Exception:
         self.fail("Should not throw any other error types")
Ejemplo n.º 6
0
 def connect_to_wwise(self):
     url = 'ws://127.0.0.1:' + str(self.spbWaapiPort.value()) + '/waapi'
     try:
         WaapiTools.Client = WaapiClient(url=url)
         WaapiTools.Client.subscribe('ak.wwise.core.project.postClosed',
                                     self.on_wwise_closed)
         self.statusbar.showMessage('Wwise已连接到' +
                                    WaapiTools.get_project_directory())
         self.btnWaapiConnect.setEnabled(False)
     except CannotConnectToWaapiException:
         self.statusbar.showMessage('无法连接到Wwise工程...')
    def test_exception_on_invalid_argument(self):
        with WaapiClient(allow_exception=True) as client:
            try:
                client.call("ak.wwise.core.getInfo", someArg=True)
            except WaapiRequestFailed as e:
                self.assertTrue(
                    e.kwargs.get("message",
                                 "").startswith("Invalid arguments."))
                return

            self.fail("Should have thrown an exception")
Ejemplo n.º 8
0
    def ww_event_creat(args):
        try:

            with WaapiClient() as client:  #"ws://127.0.0.1:8080/waapi"

                for i in args:
                    client.call("ak.wwise.core.object.create", i)

        except CannotConnectToWaapiException:
            print(
                "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
            )
Ejemplo n.º 9
0
def importer(import_paths):
    try:

        with WaapiClient() as client:  #"ws://127.0.0.1:8080/waapi"

            args = {
                "importOperation": "useExisting",
                "default": {
                    "importLanguage": "SFX"
                },
                "imports": import_paths
            }

            client.call("ak.wwise.core.audio.import", args)

    except CannotConnectToWaapiException:
        print(
            "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
        )
Ejemplo n.º 10
0
    def ww_audio_import(import_paths, language):
        try:

            with WaapiClient() as client:

                args = {
                    "importOperation": "useExisting",
                    "default": {
                        "importLanguage": {
                            'EN': 'English(US)',
                            'CN': 'Chinese',
                        }.get(language)
                    },
                    "imports": import_paths
                }

                client.call("ak.wwise.core.audio.import", args)

        except CannotConnectToWaapiException:
            print(
                "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
            )
Ejemplo n.º 11
0
def foler_creater(file_dic):

    characters = []
    for value in file_dic.values():
        if not os.path.split(os.path.dirname(value))[-1] in characters:
            characters.append(os.path.split(os.path.dirname(value))[-1])

    try:

        with WaapiClient() as client:  #"ws://127.0.0.1:8080/waapi"

            args = {
                "parent": "\\Events\\Default Work Unit",
                "type": "Folder",
                "name": "Voices",
                "onNameConflict": "merge"
            }

            client.call('ak.wwise.core.object.create',
                        args)  #creat root Voices folder

            for i in characters:

                args = {
                    "parent": "\\Events\\Default Work Unit\\Voices",
                    "type": "Folder",
                    "name": i,
                    "onNameConflict": "merge"
                }
                client.call('ak.wwise.core.object.create',
                            args)  #creat characters folders

    except CannotConnectToWaapiException:
        print(
            "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
        )
from waapi import WaapiClient, CannotConnectToWaapiException
from pprint import pprint

try:
    # Connect to Wwise via the default IP & port
    with WaapiClient() as client:

        # Call ak.wwise.core.getInfo to get the global information of Wwise and store it in the variable 'result'
        result = client.call("ak.wwise.core.getInfo")
        # In order to avoid print single line printing, you need to use pprint to print the JSON result you just got
        pprint(result)

except CannotConnectToWaapiException:
    print(
        "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
    )
Ejemplo n.º 13
0
 def test_connect_constructor(self):
     client = WaapiClient()
     self.assertIsNotNone(client)
     self.assertTrue(client.is_connected())
Ejemplo n.º 14
0
 def setUpClass(cls):
     cls.client = WaapiClient(callback_executor=PerCallbackThreadExecutor)
Ejemplo n.º 15
0
 def test_with_statement(self):
     with WaapiClient() as client:
         self.assertTrue(client.is_connected())
         # Implicit disconnect through __exit__
     self.assertFalse(client.is_connected())
Ejemplo n.º 16
0
 def test_disconnect(self):
     client = WaapiClient()
     self.assertTrue(client.is_connected())
     client.disconnect()
     self.assertFalse(client.is_connected())
Ejemplo n.º 17
0
from waapi import WaapiClient, CannotConnectToWaapiException
from pprint import pprint

try:
    client = WaapiClient()

except CannotConnectToWaapiException:
    print("Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?")

else:
    # Create the 'on_name_changed()' as a Callback Function in the subscription
    def on_name_changed(*args, **kwargs):
        # Get object type
        obj_type = kwargs.get("object", {}).get("type")
        # Get previous name
        old_name = kwargs.get("oldName")
        # Get new name
        new_name = kwargs.get("newName")

        # Use the format function to format the output information ({} represents the corresponding variable in the 'format()' function) to inform the user that the object of type XXX has been renamed from A to B
        print("Object '{}' (of type '{}') was renamed to '{}'\n".format(old_name, obj_type, new_name))
        # After the execution is complete, disconnect the WAMP connection. If you want to continue subscribing to information, you can also keep the connection
        client.disconnect()

    # Subscribe to the required topic, and use the callback function as the parameter one of the function. At the same time, use the option type as the second parameter, so that when the object name in Wwise is modified, the modified object type is returned
    handler = client.subscribe("ak.wwise.core.object.nameChanged", on_name_changed, {"return": ["type"]})

    # Print a message to remind the user that he has subscribed to 'ak.wwise.core.object.nameChanged' and suggest that the user perform a rename operation to verify that the script runs normally
    print("Subscribed 'ak.wwise.core.object.nameChanged', rename an object in Wwise")
Ejemplo n.º 18
0
 def setUpClass(cls):
     cls.client = WaapiClient(callback_executor=SequentialThreadExecutor)
# Unless required by applicable law or agreed to in writing, software distributed
# under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
# the specific language governing permissions and limitations under the License.

#!/usr/bin/env python3
from waapi import WaapiClient, CannotConnectToWaapiException
from pprint import pprint

import threading
import mido
midiOutput = mido.open_output("Wwise2MadMapperPort 1")

try:
    client = WaapiClient()
    print("Connected MIDI device: '{}'".format(midiOutput))

except CannotConnectToWaapiException:
    print(
        "Could not connect to Waapi: Is Wwise running and Wwise Authoring API enabled?"
    )

else:
    #Start Profiler
    handler = client.call("ak.wwise.core.profiler.startCapture")

    def GetRTPCsLoop():
        threading.Timer(0.01, GetRTPCsLoop).start()
        arguments = {"time": "capture"}
        result = client.call("ak.wwise.core.profiler.getRTPCs", arguments)
Ejemplo n.º 20
0
 def setUpClass(cls):
     cls.client = WaapiClient(callback_executor=AsyncioLoopExecutor)
Ejemplo n.º 21
0
import os
from waapi import WaapiClient
from tkinter import filedialog
import numpy as np

# Get files path
files = filedialog.askopenfilenames(
    initialdir ="C:/",
    filetypes =(("Text File", "*.txt"),("All Files","*.*")), 
    title = "choose your tab Delimited txt file"
    )

# Connect (default URL)
client = WaapiClient()

# RPC
for file in np.asarray(files):
    kwargs = {
        "importLanguage": "SFX", 
        "importOperation": "useExisting",
        "importFile": file,
        "autoAddToSourceControl": True }
    result = client.call("ak.wwise.core.audio.importTabDelimited", kwargs)

    print(result)

# Disconnect
client.disconnect()


Ejemplo n.º 22
0
 def setUpClass(cls):
     cls.client = WaapiClient()