// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // Global identifiers global float $aiffFO_referenceTime = 0.0; global proc aiffFO_changeInheritFileAudioOffset( int $on ) { global float $aiffFO_referenceTime; if( $on ) { // Update offset field with value from file // If not availlable, use animStart if( $aiffFO_referenceTime > 0.0 ) { timeFieldGrp -e -v1 ($aiffFO_referenceTime) aiffOffsetVal; } else { float $animStart = `playbackOptions -q -ast`; timeFieldGrp -e -v1 ($animStart) aiffOffsetVal; } } } global proc aiffFO_changeImportAudioAtStart( int $on ) { if( $on ) { // Update offsetField with animStart float $animStart = `playbackOptions -q -ast`; timeFieldGrp -e -v1 ($animStart) aiffOffsetVal; } } global proc aiffFO_changeImportAudioAtSpecifiedOffset( int $on ) { // Do not update the offset field but toggle its activation timeFieldGrp -e -enable $on aiffOffsetVal; } global proc aiffFO_FileChange( string $file ) { global float $aiffFO_referenceTime; $aiffFO_referenceTime = `file -fileMetaData -type "audio" $file`; float $animStart = `playbackOptions -q -ast`; int $currentOption = `radioButtonGrp -q -select imFileAudioOffset`; radioButtonGrp -e -enable1 ($aiffFO_referenceTime > 0.0 ) imFileAudioOffset; if( $currentOption == 1 ) { if( $aiffFO_referenceTime > 0.0 ) { timeFieldGrp -e -v1 ($aiffFO_referenceTime) aiffOffsetVal; } else { // File has no offset, display animationStart instead timeFieldGrp -e -v1 ($animStart) aiffOffsetVal; } } } global proc int aiffFileOptions ( string $parent, string $action, string $initialOptions, string $resultCallback ) // // Description: // This script posts the aiff file accessor options. // // Parameters: // $parent - the elf parent layout for this options layout. It is // always a scrollLayout. // $action - the action that is to be performed with this invokation // of this proc. Valid options are: // "query" - construct the options string and pass it // to the resultCallback. // "post" - post all the elf controls. // $resultCallback - // This is the proc to be called with the result string. // resultCallback ( string $optionsString ) // // Returns: // 1 if successfull. // 0 otherwise. // { int $result; string $currentOptions; string $optionList[]; string $optionBreakDown[]; int $index; if ($action == "post") { setUITemplate -pushTemplate DefaultTemplate; setParent $parent; frameLayout -label (uiRes("m_aiffFileOptions.kAudioOffset")) ; columnLayout -rowSpacing 5 audioOffsetLayout; // Parse options. // $currentOptions = $initialOptions; float $offset = `playbackOptions -q -ast`; int $optionIndex = 3; if (size($currentOptions) > 0) { tokenize($currentOptions, ";", $optionList); for ($index = 0; $index < size($optionList); $index++) { tokenize($optionList[$index], "=", $optionBreakDown); if ($optionBreakDown[0] == "o") { if( $optionBreakDown[1] == "fromFile" ) { $optionIndex = 1; } else if( $optionBreakDown[1] == "animStart") { $optionIndex = 2; } else { $offset = float( $optionBreakDown[1] ); } } } } radioButtonGrp -cw 1 0 -cw 2 240 -numberOfRadioButtons 3 -vr -label1 (uiRes("m_aiffFileOptions.kInherifFileAudioOffset")) -annotation1 (uiRes("m_aiffFileOptions.kInherifFileAudioOffsetAnnotation")) -changeCommand1 "aiffFO_changeInheritFileAudioOffset #1" -enable1 0 -label2 (uiRes("m_aiffFileOptions.kImportAudioAtStart")) -annotation2 (uiRes("m_aiffFileOptions.kImportAudioAtStartAnnotation")) -changeCommand2 "aiffFO_changeImportAudioAtStart #1" -label3 (uiRes("m_aiffFileOptions.kImportAudioAtSpecifiedOffset")) -annotation3 (uiRes("m_aiffFileOptions.kImportAudioAtSpecifiedOffsetAnnotation")) -changeCommand3 "aiffFO_changeImportAudioAtSpecifiedOffset #1" -select $optionIndex imFileAudioOffset; timeFieldGrp -label (uiRes("m_aiffFileOptions.kSoundFileOffset")) -v1 $offset -pre 2 aiffOffsetVal; setUITemplate -popTemplate; $result = 1; } else if ($action == "query") { int $currentOptionIndex = `radioButtonGrp -q -select imFileAudioOffset`; if( $currentOptionIndex == 1 ) { $currentOptions = "o=fromFile"; } else if( $currentOptionIndex == 2 ) { $currentOptions = "o=animStart"; } else { float $value = `timeFieldGrp -q -v1 aiffOffsetVal`; $currentOptions = "o=" + $value; } eval($resultCallback+" \""+$currentOptions+"\""); $result = 1; } else { $result = 0; } return $result; }