[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3879] contrib/py/scripts/addons/ io_import_sound_to_anim.py: -v 0.50Beta-
vlassius santos
vlassius at vlassius.com.br
Mon Oct 22 19:25:39 CEST 2012
Revision: 3879
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3879
Author: vlassius
Date: 2012-10-22 17:25:39 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
-v 0.50Beta-
Included: Auto Adjust Audio Sensity option
Included: 8 bits .wav file support
Recalibrated: Manual audio sense 1
Cosmetic: Many changes in panel and terminal window info
Corrected: Tracker_url
Corrected: a few bytes in Memory Leaks
work around: memory leak in function: bpy.ops.transform.rotate
work around: memory leak in function: bpy.ops.anim.keyframe_insert
Modified Paths:
--------------
contrib/py/scripts/addons/io_import_sound_to_anim.py
Modified: contrib/py/scripts/addons/io_import_sound_to_anim.py
===================================================================
--- contrib/py/scripts/addons/io_import_sound_to_anim.py 2012-10-22 09:26:08 UTC (rev 3878)
+++ contrib/py/scripts/addons/io_import_sound_to_anim.py 2012-10-22 17:25:39 UTC (rev 3879)
@@ -21,14 +21,14 @@
bl_info = {
"name": "Import: Sound to Animation",
"author": "Vlassius",
- "version": (0, 22),
+ "version": (0, 50),
"blender": (2, 57, 0),
"api": 37023,
"location": "Select a object -> go to the Object tab -> Import Movement From Wav File",
"description": "Extract movement from sound file. See the Object Panel at the end.",
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Import_Movement_From_Audio_File",
- "tracker_url": "",
+ "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=23565&group_id=153&atid=467",
"category": "Import-Export"}
"""
@@ -36,11 +36,21 @@
- NOTES:
- This script takes a wav file and get sound "movement" to help you in sync the movement to words in the wave file. <br>
-- Blender 2.5.7
+- Supported Audio: .wav (wave) 8 bits and 16 bits <br>
+- At least Blender 2.5.7 is necessary to run this program.
-
+-v 0.50Beta-
+ Included: Auto Adjust Audio Sensity option
+ Included: 8 bits .wav file support
+ Recalibrated: Manual audio sense 1
+ Cosmetic: Many changes in panel and terminal window info
+ Corrected: Tracker_url
+ Corrected: a few bytes in Memory Leaks
+ work around: memory leak in function: bpy.ops.transform.rotate
+ work around: memory leak in function: bpy.ops.anim.keyframe_insert
+
-v 0.22Beta-
- Included
+ Included:
Camera Rotation
Empty Location-Rotation-Scale
@@ -133,9 +143,6 @@
# Colocar Escolha do Canal!!
#
#
-# colocar relatorio de samples min, max, 90%, colocar sugestao subir/descer audio sense
-#
-#
# colocar CANCELAR com ESC
#
#
@@ -352,6 +359,8 @@
if context.scene.imp_sound_to_anim.bArrayCriado:
for i in range(len(array)):
+ #print(array[i])
+
ival=array[i]/iDivScala
#valor pequeno demais, vai dar zero na hora de aplicar
if ival < 0.001:
@@ -446,31 +455,48 @@
if bRotacao:
if iRotateValAnt!=0:
- bpy.ops.transform.rotate(value= (iRotateValAnt*-1,), axis=(iRotationAxisBaseX, iRotationAxisBaseY, iRotationAxisBaseZ), constraint_axis=(bRotationX, bRotationY, bRotationZ), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
+ # memory leak
+ #bpy.ops.transform.rotate(value= (iRotateValAnt*-1), axis=(iRotationAxisBaseX, iRotationAxisBaseY, iRotationAxisBaseZ), constraint_axis=(bRotationX, bRotationY, bRotationZ), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
+ bpy.context.active_object.rotation_euler= ((iRotateValAnt*-1)+iRotationAxisBaseX)*bRotationX , ((iRotateValAnt*-1)+iRotationAxisBaseY)*bRotationY , ((iRotateValAnt*-1)+iRotationAxisBaseZ)*bRotationZ
- bpy.ops.transform.rotate(value= (ival*iRotationNeg,), axis=(iRotationAxisBaseX, iRotationAxisBaseY, iRotationAxisBaseZ), constraint_axis=(bRotationX, bRotationY, bRotationZ), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
+ #memory leak
+ #bpy.ops.transform.rotate(value= (ival*iRotationNeg), axis=(iRotationAxisBaseX, iRotationAxisBaseY, iRotationAxisBaseZ), constraint_axis=(bRotationX, bRotationY, bRotationZ), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
+ bpy.context.active_object.rotation_euler= ((ival*iRotationNeg)+ iRotationAxisBaseX)* bRotationX, ((ival*iRotationNeg)+ iRotationAxisBaseY)* bRotationY, ((ival*iRotationNeg)+ iRotationAxisBaseZ)* bRotationZ
iRotateValAnt= ival*iRotationNeg
- if bEixo and not bEscala and not bRotacao:
- bpy.ops.anim.keyframe_insert_menu(type='Location')
+ ob = bpy.context.active_object
+
+ if bEixo:
+ ob.keyframe_insert(data_path="location")
- if bRotacao and not bEixo and not bEscala:
- bpy.ops.anim.keyframe_insert_menu(type='Rotation')
+ if bRotacao:
+ ob.keyframe_insert(data_path="rotation_euler")
- if bEscala and not bEixo and not bRotacao:
- bpy.ops.anim.keyframe_insert_menu(type='Scaling')
+ if bEscala:
+ ob.keyframe_insert(data_path="scale")
+
+
+ # *** Problem Memory Leak ***
+ #if bEixo and not bEscala and not bRotacao:
+ # bpy.ops.anim.keyframe_insert(type='Location')
+
+ #if bRotacao and not bEixo and not bEscala:
+ # bpy.ops.anim.keyframe_insert(type='Rotation')
+
+ #if bEscala and not bEixo and not bRotacao:
+ # bpy.ops.anim.keyframe_insert(type='Scaling')
- if bEixo and bRotacao:
- bpy.ops.anim.keyframe_insert_menu(type='LocRot')
+ #if bEixo and bRotacao:
+ # bpy.ops.anim.keyframe_insert(type='LocRot')
- if bEscala and bEixo:
- bpy.ops.anim.keyframe_insert_menu(type='LocScale')
+ #if bEscala and bEixo:
+ # bpy.ops.anim.keyframe_insert(type='LocScale')
- if bEixo and bRotacao and bEscala:
- bpy.ops.anim.keyframe_insert_menu(type='LocRotScale')
+ #if bEixo and bRotacao and bEscala:
+ # bpy.ops.anim.keyframe_insert(type='LocRotScale')
- if bEscala and bRotacao:
- bpy.ops.anim.keyframe_insert_menu(type='RotScale')
+ #if bEscala and bRotacao:
+ # bpy.ops.anim.keyframe_insert(type='RotScale')
print("Importing Blender Frame: "+str(i)+"\tof "+str(len(array)-1) + "\tValue: "+ str(ival))
@@ -503,7 +529,7 @@
# Sound Converter
#==================================================================================================
-def SoundConv(File, DivSens, Sensibil, Resol, context):
+def SoundConv(File, DivSens, Sensibil, Resol, context, bAutoSense):
try:
Wave_read= wave.open(File, 'rb')
@@ -518,11 +544,19 @@
ChkCompr= Wave_read.getcomptype()
if ChkCompr != "NONE":
- print('Formato de Compressão Nao Suportado ', ChkCompr)
+ print('Sorry, this compressed Format is NOT Supported ', ChkCompr)
+ context.scene.imp_sound_to_anim.Info_Import= "Sorry, this compressed Format is NOT Supported "
return False
- # com 8 bits/S - razao Sample/s por resolucao
+ if SampW > 2:
+ context.scene.imp_sound_to_anim.Info_Import= "Sorry, supported .wav files 8 and 16 bits only"
+ print('Sorry, supported .wav files 8 and 16 bits only')
+ return False
+
+ context.scene.imp_sound_to_anim.Info_Import=""
+
# usado para achar contorno da onda - achando picos
+ # numero de audio frames para cada video frame
BytesResol= int(FrameR/Resol)
# com 8 bits/S - razao Sample/s por resolucao
@@ -538,91 +572,187 @@
print(strftime("Go! %H:%M:%S"))
print("================================================================")
print('')
- print('Audio Time: \t ' + str(NumFr//FrameR) + 's (' + str(NumFr//FrameR//60) + 'min)')
- print('Interactions: \t', BytesDadosTotProcess)
- print('Audio Frames: \t', NumFr)
- print('Frame Rate: \t', FrameR)
- print('Chan in File: \t', NumCh)
- print('Bit/Samp/Chan: \t', SampW*8)
- print('Channel in use:\t 1')
- print('Sensitivity: \t', Sensibil+1)
- print('DivMovim: \t', DivSens)
+ print('Total Audio Time: \t ' + str(NumFr//FrameR) + 's (' + str(NumFr//FrameR//60) + 'min)')
+ print('Total # Interactions: \t', BytesDadosTotProcess)
+ print('Total Audio Frames: \t', NumFr)
+ print('Frames/s: \t\t ' + str(FrameR))
+ print('# Chanels in File: \t', NumCh)
+ print('Channel in use:\t\t 1')
+ print('Bit/Sample/Chanel: \t ' + str(SampW*8))
+ print('# Frames/Act: \t\t', DivSens)
+
+ if bAutoSense==0:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list