Red9_Audio

Red9 Audio is the module for all audio handling within the Red9 pack.

This includes the wrapper to the new audio compile tools for mixing multiple wavs inside Maya to a single merged track, allowing you to finally playblast multiple separate audio nodes! Why the hell Autodesk haven’t done this I have no idea as it’s a major issue when you’re dealing with facial sequences. There’s is a ‘compile’ flag in the playblast command but it’s never worked.

This is the Audio library of utils used throughout the modules

Core Functions

milliseconds_to_Timecode(milliseconds[, ...])
milliseconds_to_frame(milliseconds[, framerate])
timecode_to_milliseconds(timecode[, smpte, ...])
timecode_to_frame(timecode[, smpte, framerate])
frame_to_timecode(frame[, smpte, framerate])
frame_to_milliseconds(frame[, framerate])
combineAudio() this is a logic wrapper over the main compile call in the AudioHandler
inspect_wav() Simple UI to show internal Wav file properties.
getMediaFileMetaData

Main Classes

AudioHandler([audio]) process on multiple audio nodes within the Maya scene, ie, already loaded
AudioNode([audioNode, filepath]) Single AudioNode handler for simple audio management object
bind_pro_audio()

This is a wrap to import the pro_audio extensions. We have to lazy load this to avoid cyclic issues in the boot and wrapping it like this makes it easy to consume in the classes

milliseconds_to_Timecode(milliseconds, smpte=True, framerate=None)
milliseconds_to_frame(milliseconds, framerate=None)
timecode_to_milliseconds(timecode, smpte=True, framerate=None)
timecode_to_frame(timecode, smpte=True, framerate=None)
frame_to_timecode(frame, smpte=True, framerate=None)
frame_to_milliseconds(frame, framerate=None)
combineAudio()

this is a logic wrapper over the main compile call in the AudioHandler I wanted to keep things simple in the base class.

audioSelected()
audioPathLoaded(filepath)

return any soundNodes in Maya that point to the given audio path

inspect_wav()

Simple UI to show internal Wav file properties. Supports full Broadcast Wav inspection

class AudioHandler(audio=None)

Bases: object

process on multiple audio nodes within the Maya scene, ie, already loaded

Note

all BWav and Timecode support is in the Red9 ProPack

audioNodes
mayaNodes
<<<<<<< HEAD getAudioInRange(time=(), asNodes=True, start_inRange=True, end_inRange=True)
======= getAudioInRange(time=(), asNodes=True) >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e

return any audio in the handler within a given timerange

Parameters:
  • time – tuple, (min,max) timerange within which returned audio has fall within else it’s ignored.
  • asNodes – return the data as r9Audio.AudioNodes
  • <<<<<<< HEAD
  • start_inRange – check is the testRange[0] value falls fully in the baseRange
  • end_inRange – check is the testRange[1] value falls fully in the baseRange
  • ======= >>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e

Note

if you pass in time as (None, 100) then we only validate against the end time. if we pass in time as (10, None) we only validate against the start time else we validate that testRange is fully within the times

getOverallRange()

return the overall frame range of the given audioNodes (min/max)

getOverallBwavTimecodeRange(ms=False)
: PRO_PACK
:
return the overall internal BWAV timecode range for the given nodes. Note this is the internal timecode plus the length of the files
Parameters:ms – return the (minV,maxV) in milliseconds or SMPTE timecode
setTimelineToAudio(audioNodes=None)

set the current TimeSlider to the extent of the given audioNodes

setActive()
offsetBy(offset)

offset all audioNode by a given frame offset

offsetRipple(*args)

offset all audioNodes so that they ripple in the order of self.audioNodes

offsetTo(startFrame)

offset all audio such that they start relative to a given frame, takes the earliest startpoint of the given audio to calculate how much to offset by

muteSelected(state=True)
lockTimeInputs(state=True)

lock the time attrs of thie audio nodes so they can’t be slipped or moved by accident

deleteSelected()
formatNodes_to_Path()

rename the sound nodes to match their internal audioPath filename

bwav_sync_to_Timecode(relativeToo=None, offset=0, *args)
: PRO_PACK
:
process either selected or all audio nodes and IF they are found to be BWav’s with valid timecode references, sync them in Maya such that their offset = Bwav’s timecode ie: sync them on the timeline to the bwavs internal timecode.
Parameters:
  • relativeToo – This is fucking clever, even though I do say so. Pass in another bWav node and I calculate it’s internal timecode against where it is in the timeline. I then use any difference in that nodes time as an offset for all the other nodes in self.audioNodes. Basically syncing multiple bwav’s against a given sound.
  • offset – given offset to pass to the sync call, does not process with the relativeToo flag
combineAudio(filepath)

Combine audio tracks into a single wav file. This by-passes the issues with Maya not playblasting multip audio tracks.

Parameters:filepath – filepath to store the combined audioTrack

TODO: Deal with offset start and end data + silence

class AudioNode(audioNode=None, filepath=None)

Bases: object

Single AudioNode handler for simple audio management object

“Broadcast Wav” format now supported using specs from : https://tech.ebu.ch/docs/tech/tech3285.pdf

path
audioNode
sampleRate

sample rate in milliseconds

sample_width

bytes per sample, is converted by the sample_bits into bitrate

sample_bits

bit rate taken from the bytes per sample : 4,8,16,24 bit

channels

number of channels 1=mone, 2=stereo

dBFS

loudness of the AudioSegment in dBFS (db relative to the maximum possible loudness)

max_dBFS

The highest amplitude of any sample in the AudioSegment, in dBFS (relative to the highest possible amplitude value).

startFrame

Maya start frame of the sound node

endFrame

Note in batch mode we calculate via the Wav duration NOT the Maya audioNode length as it’s invalid under batch mode!

startTime

: PRO_PACK : Maya start time of the sound node in milliseconds

endTime

: PRO_PACK : Maya end time of the sound node in milliseconds

offset

simply get the offset

isBwav()

: PRO_PACK : validate if the given source Wav is a BWav or not

bwav_getHeader()

: PRO_PACK : get the internal BWav header data from the wav if found

bwav_timecodeMS()

: PRO_PACK : read the internal timecode reference from the bwav and convert that number into milliseconds

bwav_timecodeReference()

: PRO_PACK : if is BWaw return the internal timeReference

bwav_timecodeFormatted(smpte=True, framerate=None)

: PRO_PACK : if is Bwav return the internal timecode & convert from milliseconds into timecode

Parameters:
  • smpte – format the timecode HH:MM:SS:FF where FF is frames, else milliseconds
  • framerate – when using smpte this is the framerate used in the FF block
bwav_sync_to_Timecode(offset=0)

: PRO_PACK : given that self is a Bwav and has timecode reference, sync it’s position in the Maya timeline to match

Parameters:offset – offset to apply to the internal timecode of the given wav’s
isConnected_AudioGrp()

: PRO_PACK : is this audioNode connected to a Pro_ AudioGrp metaNode for asset management in the Pro systems

isValid()

If the audionode is loaded in maya then valid is if that node we’re pointing to exists If the audionode is NOT loaded and we just have a pth check if that path exists

delete()

Maya delete the sound node

offsetTime(offset)

offset the time of this audioNode instance

Parameters:offset – amount to offset
importAndActivate(active=True)

If self was instantiated with filepath then this will import that wav into Maya and activate it on the timeline. Note that if there is already an instance of a sound node in Maya that points to this path them the class will bind itself to that node.

Parameters:active – do we set the imported audio to be active on the timerange in Maya
>>> # example of use:
>>> audio = r9Audio.AudioNode(filepath = 'c:/my_audio.wav')
>>> audio.importAndActivate()
setActive()

Set sound node as active on the timeSlider

getLengthFromWav()

This uses the wav itself bypassing the Maya handling, why? In maya.standalone the audio isn’t loaded correctly and always is of length 1!

setTimeline()

Set the Maya timeline to the duration oft he sound

mute(state=True)

Maya node, mute the sound

openAudioPath()
formatAudioNode_to_Path()

rename the AudioNode so it ties to the wav name

lockTimeInputs(state=True)

lock the audio in time so it can’t be accidentally shifted

Parameters:state – the lock state of the node, True or False
isCompiled

return if the audioNode in Maya was generated via the compileAudio call in the AudioHandler.

stampCompiled(audioNodes)

Used by the Audio compiler - stamp the audioNodes from which this audio track was compiled from

Parameters:audioNodes – the audioNodes being compiled
select()
class AudioToolsWrap

Bases: object

classmethod show()
offsetSelectedBy(direction, *args)
offsetSelectedTo(*args)
offsetRipple(*args)
sync_bwavsRelativeToo(*args)

PRO_PACK

sync_bwavs(*args)

PRO_PACK

timecodeHud(*args)
<<<<<<< HEAD

PRO_PACK

=======
>>>>>>> d7ab8a039c4da0838a07bf4a9ec3ad957667b21e