Search code examples
pythonaudiomaya

Maya Python: offsetting a sound file


still pretty new to python.

i am trying to offset a soundfile (.wav format) in maya, so it would start at frame 1001.

i tried using the sound command with the file and offset flags.

cmds.sound(file="soundName.wav", offset=1001)

Also tried without the ".wav" suffix, as in the audio options tab the filename ist just "soundName", without suffix. Not working tho either.

i just get the error:

file is not a sound file

Its almost as if the wrong thing gets selected, which may not be a soundfile. Because why else would it tell me "soundName" is not a soundfile when it clearly is? Or does maya not interpret WAVs as soundfile? is it just due to the file format?

If i offset the WAV manually, its working fine and maya is playing the file as it should, so maya is clearly working with WAVs, maybe its just the command not working with WAVs?

what am i missing here ?

and why does stackoverflow keeps cutting my first sentence off my posts? Its always as if i wouldnt say hello, which i usually do.


Solution

  • It definitely works. Don't forget to assign a full path.

    import maya.cmds as cmds
    
    cmds.sound(file="/Users/swift/Desktop/soundFile.wav", offset=50)
    

    If Maya doesn't wanna play .wav file, try to change a codec and other parameters in this file. You need to save your sound file with the following settings: linear PCM encoding, 8-bit unsigned integer, sample rate 22kHz or 44,1kHz.