// =========================================================================== // 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 proc MASHcheckAutioType ( string $nodeName ) { if ( `objExists $nodeName` == 0 ) return; //are we using the modern connection style? Enable this attr if so. string $conns[] = `listConnections -d on -s off ($nodeName+".outputPoints")`; int $numConns = size($conns); if ($numConns) { editorTemplate -dimControl $nodeName "transformationSpace" false; } else { editorTemplate -dimControl $nodeName "transformationSpace" true; } string $nodeAttr = $nodeName + ".outputMode"; int $value = `getAttr $nodeAttr`; if ($value) { editorTemplate -dimControl $nodeName "transformationSpace" true; } else { editorTemplate -dimControl $nodeName "transformationSpace" false; } } global proc AEMASH_AudioTemplate( string $nodeName ) { editorTemplate -beginScrollLayout; python("import MASH.nodeHeaders; MASH.nodeHeaders.addHeader('" + $nodeName + "', 'Audio')") editorTemplate -endLayout; editorTemplate -label (getPluginResource("MASH", "kOffsetType")) -addControl "offsetType"; editorTemplate -label (getPluginResource("MASH", "kNodeMode")) -addControl "nodeMode"; editorTemplate -label (getPluginResource("MASH", "kOutputMode")) -addControl "outputMode" "MASHcheckAutioType"; editorTemplate -callCustom "AEMASHaudioFilenameNew" "AEMASHaudioFilenameReplace" "filename"; editorTemplate -addSeparator; editorTemplate -callCustom "AEAudioLegacyCheck" "AEAudioLegacyCheckEdit" ""; editorTemplate -label (getPluginResource("MASH", "kTransformationSpace")) -addControl "transformationSpace"; AEaddRampControl ($nodeName+".frequencyGraph"); editorTemplate -callCustom "MASHaudioEqBuildQt" "MASHaudioEqUpdateQt" ""; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kMaxBands")) -addControl "maxBands"; editorTemplate -label (getPluginResource("MASH", "kFiltering")) -addControl "filterStrength"; editorTemplate -label (getPluginResource("MASH", "kSmoothing")) -addControl "timeSmoothing"; editorTemplate -label (getPluginResource("MASH", "kLowerThresh")) -addControl "minThreshold"; editorTemplate -label (getPluginResource("MASH", "kUpperThresh")) -addControl "maxThreshold"; editorTemplate -beginLayout (getPluginResource("MASH", "kStrength")) -collapse 0; editorTemplate -label (getPluginResource("MASH", "kStrength")) -addControl "Envelope"; editorTemplate -label (getPluginResource("MASH", "kRandStrength")) -addControl "randEnvelope"; editorTemplate -label (getPluginResource("MASH", "kStepStrength")) -addControl "StepEnvelope"; editorTemplate -addSeparator; editorTemplate -label (getPluginResource("MASH", "kStrengthMap")) -addControl "mColour"; editorTemplate -label (getPluginResource("MASH", "kMapProjAxis")) -addControl "mapDirection"; editorTemplate -callCustom "MASHmapHelperButton" "MASHmapHelperButtonEdit" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kFalloffObject")) -collapse 1; editorTemplate -callCustom "MASHfalloffButtons" "MASHfalloffButtonsEdit" ""; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kTime")) -collapse 1; editorTemplate -label (getPluginResource("MASH", "kTime")) -addControl "time"; editorTemplate -label (getPluginResource("MASH", "kTimeOffset")) -addControl "timeOffset"; editorTemplate -label (getPluginResource("MASH", "kTimeStep")) -addControl "timeStep"; editorTemplate -label (getPluginResource("MASH", "kModTime")) -addControl "modifiedTime"; editorTemplate -label (getPluginResource("MASH", "kSoundLength")) -addControl "soundLength"; editorTemplate -endLayout; editorTemplate -beginLayout (getPluginResource("MASH", "kAdvancedOptions")) -collapse 1; editorTemplate -suppress "samplesNumber"; editorTemplate -label (getPluginResource("MASH", "kFFTScaling")) -addControl "fourierScaling"; editorTemplate -label (getPluginResource("MASH", "kOutFreqAtt")) -addControl "eqBOutput"; editorTemplate -label (getPluginResource("MASH", "kVolumeMode")) -addControl "volumeMode"; editorTemplate -label (getPluginResource("MASH", "kOutVolume")) -addControl "outVolume"; editorTemplate -endLayout; editorTemplate -suppress "inIterations"; AEdependNodeTemplate $nodeName; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; editorTemplate -suppress "sampleRate"; MASHsupressLegacyControls(); } global proc MASHaudioEqBuildQt(string $nodeName) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; string $nodeType = `nodeType($nodeName)`; string $layout = ($nodeType+"audioEqPointsLayout"); python("import MASHsingleOutputQtWidget"); rowLayout -numberOfColumns 2 -columnWidth2 139 250 $layout; text -w 105 -h 20 -vis 1 -label (getPluginResource("MASH", "kAudioEq")) -align "right" -font "plainLabelFont" ; //get python to create the widget, include the desired nodeType as an arguement python("MASHsingleOutputQtWidget.build_qt_widget('" + $layout + "', '" + $nodeName + "', 'MASH_Points', 'outputPoints', 'inputPoints', 'AddAudioEq')"); setParent..; } global proc MASHaudioEqUpdateQt(string $nodeName ) { string $buffer[]; tokenize($nodeName, ".", $buffer); $nodeName = $buffer[0]; string $nodeType = `nodeType($nodeName)`; string $layout = ($nodeType+"audioEqPointsLayout"); python("import MASHsingleOutputQtWidget"); python("MASHsingleOutputQtWidget.update_qt_widget('" + $layout + "', '" + $nodeName + "', 'MASH_Points', 'outputPoints', 'inputPoints', 'AddAudioEq')"); } // // Check for legacy controls and disable the new controls accordingly // global proc AEAudioLegacyCheck ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); //are we using the modern connection style? This determines what attributes are shown. string $conns[] = `listConnections -d on -s off ($nodeName[0]+".outputArray")`; int $numConns = size($conns); int $newMode = 1; if ($numConns) { $newMode = 0; //bool needed for later inversion } // NEW CONTROLS AEAddMashCheckboxControl ( ($nodeName[0]+".enablePosition"), "mashAudioEnablePosGrp", $newMode, (getPluginResource("MASH", "kEnablePos")) ); AEAddMashCheckboxControl ( ($nodeName[0]+".enableRotation"), "mashAudioEnableRotGrp", $newMode, (getPluginResource("MASH", "kEnableRot")) ); AEAddMashCheckboxControl ( ($nodeName[0]+".enableScale"), "mashAudioEnableScaleGrp", $newMode, (getPluginResource("MASH", "kEnableScale")) ); attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kPositionX")) -at ($nodeName[0]+".positionX") mashAudioPosXSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kPositionY")) -at ($nodeName[0]+".positionY") mashAudioPosYSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kPositionZ")) -at ($nodeName[0]+".positionZ") mashAudioPosZSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kRotationX")) -at ($nodeName[0]+".rotationX") mashAudioRotXSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kRotationY")) -at ($nodeName[0]+".rotationY") mashAudioRotYSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kRotationZ")) -at ($nodeName[0]+".rotationZ") mashAudioRotZSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kScaleX")) -at ($nodeName[0]+".scaleX") mashAudioScaleXSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kScaleY")) -at ($nodeName[0]+".scaleY") mashAudioScaleYSliderGrp; attrFieldSliderGrp -vis $newMode -label (getPluginResource("MASH", "kScaleZ")) -at ($nodeName[0]+".scaleZ") mashAudioScaleZSliderGrp; attrFieldSliderGrp -vis (!$newMode) -label (getPluginResource("MASH", "kAmpScale")) -at ($nodeName[0]+".ampScale") mashAudioAmpScaleGrp; AEAddMashCheckboxControl ( ($nodeName[0]+".enableX"), "mashAudioEnableXGrp", (!$newMode), (getPluginResource("MASH", "kEnableX")) ); AEAddMashCheckboxControl ( ($nodeName[0]+".enableY"), "mashAudioEnableYGrp", (!$newMode), (getPluginResource("MASH", "kEnableY")) ); AEAddMashCheckboxControl ( ($nodeName[0]+".enableZ"), "mashAudioEnableZGrp", (!$newMode), (getPluginResource("MASH", "kEnableZ")) ); } global proc AEAudioLegacyCheckEdit ( string $attr ) { string $nodeName[]; tokenize($attr, ".", $nodeName); //are we using the modern connection style? This determines what attributes are shown. string $conns[] = `listConnections -d on -s off ($nodeName[0]+".outputArray")`; int $numConns = size($conns); int $newMode = 1; if ($numConns) { $newMode = 0; //bool needed for later inversion } // NEW CONTROLS attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".positionX") mashAudioPosXSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".positionY") mashAudioPosYSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".positionZ") mashAudioPosZSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".rotationX") mashAudioRotXSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".rotationY") mashAudioRotYSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".rotationZ") mashAudioRotZSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".scaleX") mashAudioScaleXSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".scaleY") mashAudioScaleYSliderGrp; attrFieldSliderGrp -e -vis $newMode -at ($nodeName[0]+".scaleZ") mashAudioScaleZSliderGrp; AEAddMashCheckboxControlEdit ( ($nodeName[0]+".enablePosition"), "mashAudioEnablePosGrp", $newMode ); AEAddMashCheckboxControlEdit ( ($nodeName[0]+".enableRotation"), "mashAudioEnableRotGrp", $newMode ); AEAddMashCheckboxControlEdit ( ($nodeName[0]+".enableScale"), "mashAudioEnableScaleGrp", $newMode ); attrFieldSliderGrp -e -vis (!$newMode) -at ($nodeName[0]+".ampScale") mashAudioAmpScaleGrp; AEAddMashCheckboxControlEdit ( ($nodeName[0]+".enableX"), "mashAudioEnableXGrp", (!$newMode) ); AEAddMashCheckboxControlEdit ( ($nodeName[0]+".enableY"), "mashAudioEnableYGrp", (!$newMode) ); AEAddMashCheckboxControlEdit ( ($nodeName[0]+".enableZ"), "mashAudioEnableZGrp", (!$newMode) ); } global proc AEMASHaudioFileBrowser( string $cmd ) { string $workspace = `workspace -q -fn`; setWorkingDirectory $workspace "audio" "audio"; fileBrowser ($cmd, (getPluginResource("MASH", "kSelectAudio")), "audio", 0); } global proc AEMASHchangeSoundfile ( string $filename ) { string $nodeName[]; tokenize ($filename, ".", $nodeName); string $newValue = `textField -q -fileName audioNameField`; sound -e -f $newValue $nodeName[0]; } global proc int AEMASHsoundUpdateFilename ( string $filename, string $file, string $fileType ) { string $oldFileName = `textField -q -fileName audioNameField`; textField -edit -text $file audioNameField; if ( catch( `AEchangeSoundfile $filename` ) ) { // Setting the sound failed, go back to the old file name // textField -edit -text $oldFileName audioNameField; return false; } return true; } global proc AEMASHaudioFilenameNew ( string $fileAttribute ) { string $nodeName[]; tokenize ($fileAttribute, ".", $nodeName); setUITemplate -pst attributeEditorTemplate; columnLayout -adj true; string $conFilename = `getAttr ($nodeName[0] + ".filename")`; rowLayout -nc 3; text -label (uiRes("m_AEaudioTemplate.kFilename")) filenameName; textField -fileName $conFilename audioNameField; symbolButton -image "navButtonBrowse.png" browseSoundfiles; setParent ..; setParent ..; setUITemplate -ppt; AEMASHaudioFilenameReplace( $fileAttribute ); } global proc int AEMASHassignAudioCB( string $fileAttribute, string $filename, string $fileType ) { setAttr $fileAttribute -type "string" $filename; string $currentDir = `workspace -q -dir`; retainWorkingDirectory ($currentDir); return true; } global proc int AEMASHaudioFilenameReplace ( string $fileAttribute ) { connectControl -fileName audioNameField $fileAttribute; string $nodeName[]; tokenize ($fileAttribute, ".", $nodeName); string $conFilename; if ( catch( $conFilename = `getAttr ($nodeName[0] + ".filename")` ) ) { string $warnMsg = (uiRes("m_AEaudioTemplate.kCouldNotGetFilename")); $warnMsg = `format -s $nodeName[0] $warnMsg`; warning ( $warnMsg ); return false; } string $command = "AEMASHassignAudioCB "+" "+$fileAttribute; textField -e -cc ("AEMASHchangeSoundfile " + $fileAttribute) audioNameField; button -e -c ("AEMASHaudioFileBrowser \"" + $command + "\"") browseSoundfiles; return true; }