[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3858] contrib/py/scripts/addons/ io_import_sound_to_anim.py: Hello World :-)

Daniel Salazar - 3Developer.com zanqdo at gmail.com
Mon Oct 15 18:58:48 CEST 2012


What is this? Always wrote a decent commit message.

Daniel Salazar
patazstudio.com


On Mon, Oct 15, 2012 at 7:38 AM, vlassius santos
<vlassius at vlassius.com.br> wrote:
> Revision: 3858
>           http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3858
> Author:   vlassius
> Date:     2012-10-15 13:38:47 +0000 (Mon, 15 Oct 2012)
> Log Message:
> -----------
>    Hello World :-)
>
> Added Paths:
> -----------
>     contrib/py/scripts/addons/io_import_sound_to_anim.py
>
> Added: contrib/py/scripts/addons/io_import_sound_to_anim.py
> ===================================================================
> --- contrib/py/scripts/addons/io_import_sound_to_anim.py                                (rev 0)
> +++ contrib/py/scripts/addons/io_import_sound_to_anim.py        2012-10-15 13:38:47 UTC (rev 3858)
> @@ -0,0 +1,1100 @@
> +#!/usr/bin/python3
> +# To change this template, choose Tools | Templates
> +# and open the template in the editor.
> +#  ***** GPL LICENSE BLOCK *****
> +#
> +#  This program is free software: you can redistribute it and/or modify
> +#  it under the terms of the GNU General Public License as published by
> +#  the Free Software Foundation, either version 3 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will be useful,
> +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
> +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +#  GNU General Public License for more details.
> +#
> +#  You should have received a copy of the GNU General Public License
> +#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +#  All rights reserved.
> +#  ***** GPL LICENSE BLOCK *****
> +
> +bl_info = {
> +    "name": "Import: Sound to Animation",
> +    "author": "Vlassius",
> +    "version": (0, 22),
> +    "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_Fom_Audio_File",
> +    "tracker_url": "",
> +    "category": "Import-Export"}
> +
> +"""
> +-- Extract movement from sound file, to help in animation - import script --<br>
> +
> +- 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
> +
> +
> +-v 0.22Beta-
> +    Included
> +    Camera Rotation
> +    Empty Location-Rotation-Scale
> +
> +
> +-v 0.21Beta-
> +    Changed just the meta informations like version and wiki page.
> +
> +
> +-v 0.20 Beta-
> +    New Panel
> +
> +
> +-v 0.1.5 Beta-
> +    Change in API-> Properties
> +    Included the button "Get FPS from Scene" due to a problem to get it in the start
> +    Return to Frame 1 after import
> +    Filter .wav type file (by batFINGER)
> +
> +-v 0.1.4 Beta-
> +    If choose negative in rotation, auto check the rotation negative to Bones
> +    change in register()  unregister():
> +
> +-v 0.1.3 Beta-
> +    File Cleanup
> +    Change to bl_info.
> +    Cosmetic Changes.
> +    Minor change in API in how to define buttons.
> +    Adjust in otimization.
> +
> +-v 0.1.2 Beta
> +change in API- Update function bpy.ops.anim.keyframe_insert_menu
> +
> +-v 0.1.1 Beta
> +change in API- Update property of  window_manager.fileselect_add
> +
> +-v 0.1.0 Beta
> +new - Added support to LAMP object
> +new - improved flow to import
> +new - check the type of object before show options
> +bug - option max. and min. values
> +change- Updated scene properties for changes in property API.
> +        See http://lists.blender.org/pipermail/bf-committers/2010-September/028654.html
> +
> +new flow:
> +          1) Process the sound file
> +          2) Show Button to import key frames
> +
> +
> +- v0.0.4 ALPHA
> +new - Added destructive optimizer option - LostLestSignificativeDigit lost/total -> 10/255 default
> +new - Visual Graph to samples
> +new - Option to just process audio file and do not import - this is to help adjust the audio values
> +new - Get and show automatically the FPS (in proper field) information taking the information from scene
> +bug- Display sensitivity +1
> +bug - Corrected location of the script in description
> +
> +- v0.0.3
> +Main change: Corrected to work INSIDE dir /install/linux2/2.53/scripts/addons
> +Corrected position of label "Rotation Negative"
> +Added correct way to deal with paths in Python os.path.join - os.path.normpath
> +
> +- v0.0.2
> +Corrected initial error (Register() function)
> +Corrected some labels R. S. L.
> +Turned off "object field" for now
> +Changed target default to Z location
> +
> +- v0.0.1
> +Initial version
> +
> +
> +
> +Credit to:
> +Vlassius
> +
> +- http://vlassius.com.br
> +- vlassius at vlassius.com.br
> +
> +"""
> +
> +import bpy
> +from bpy.props import *
> +#from io_utils import ImportHelper
> +import wave
> +
> +#TODO
> +#    Arrumar - não tem rotacao para objeto - so transformacao
> +#    alterar OBJETO NOMEADO
> +
> +#    Colocar Escolha do Canal!!
> +#
> +#
> +#    colocar relatorio de samples min, max, 90%, colocar sugestao subir/descer audio sense
> +#
> +#
> +#   colocar CANCELAR com ESC
> +#
> +#
> +
> +
> +
> +#para deixar array global
> +def _Interna_Globals(BytesDadosTotProcess, context):
> +    global array
> +
> +    array= bytearray(BytesDadosTotProcess)  # cria array
> +    context.scene.imp_sound_to_anim.bArrayCriado=True
> +
> +
> +def wavimport(context):
> +    #==================================================================================================
> +    # Insert Key Frame
> +    #==================================================================================================
> +
> +#    print("Inside Wave Import...")
> +
> +    iDivScala= int(context.scene.imp_sound_to_anim.action_escale)     #scala do valor do movimento. [se =1 - 0 a 255 ] [se=255 - 0,00000 a 1,00000] [se=1000 - 0 a 0.255]
> +
> +    bNaoValorIgual=True
> +    if context.scene.imp_sound_to_anim.action_valor_igual: bNaoValorIgual= False    # não deixa repetir valores
> +
> +    iStartFrame= int(context.scene.imp_sound_to_anim.frames_initial)
> +
> +    iMaxValue= context.scene.imp_sound_to_anim.action_max_value
> +    iMinValue= context.scene.imp_sound_to_anim.action_min_value
> +
> +    bEscala=bRotacao=bEixo=False
> +    if context.scene.imp_sound_to_anim.import_type=='imp_t_Scale':
> +        bEscala=True;
> +
> +    if context.scene.imp_sound_to_anim.import_type=='imp_t_Rotation':
> +        bRotacao=True;
> +
> +    if context.scene.imp_sound_to_anim.import_type=='imp_t_Location':
> +        bEixo=True;
> +
> +    # atencao, nao é boolean
> +    iEixoXneg= iEixoYneg= iEixoZneg=1
> +    # atencao, nao é boolean
> +    iRotationNeg=1
> +    # atencao, nao é boolean
> +    iEscalaYneg= iEscalaZneg= iEscalaXneg=1
> +    bEixoX=bEixoY=bEixoZ=bEscalaX=bEscalaY=bEscalaZ=bRotationX=bRotationY=bRotationZ=False
> +
> +    # LOCAL 1
> +    if context.scene.imp_sound_to_anim.import_where1== 'imp_w_x':
> +        bEixoX=True
> +        bEscalaX=True
> +        bRotationX=True
> +
> +    if context.scene.imp_sound_to_anim.import_where1== 'imp_w_y':
> +        bEixoY=True
> +        bEscalaY=True
> +        bRotationY=True
> +
> +    if context.scene.imp_sound_to_anim.import_where1== 'imp_w_z':
> +        bEixoZ=True
> +        bEscalaZ=True
> +        bRotationZ=True
> +
> +    if context.scene.imp_sound_to_anim.import_where1== 'imp_w_-x':
> +        bEixoX=True
> +        bEscalaX=True
> +        bRotationX=True
> +        iEixoXneg=-1
> +        iEscalaXneg=-1
> +        iRotationNeg=-1
> +
> +    if context.scene.imp_sound_to_anim.import_where1== 'imp_w_-y':
> +        bEixoY=True
> +        bEscalaY=True
> +        bRotationY=True
> +        iEixoYneg=-1
> +        iRotationNeg=-1
> +        iEscalaYneg=-1
> +
> +    if context.scene.imp_sound_to_anim.import_where1== 'imp_w_-z':
> +        bEixoZ=True
> +        bEscalaZ=True
> +        bRotationZ=True
> +        iEixoZneg=-1
> +        iRotationNeg=-1
> +        iEscalaZneg=-1
> +
> +
> +    # LOCAL 2
> +    if context.scene.imp_sound_to_anim.import_where2== 'imp_w_x':
> +        bEixoX=True
> +        bEscalaX=True
> +        bRotationX=True
> +
> +    if context.scene.imp_sound_to_anim.import_where2== 'imp_w_y':
> +        bEixoY=True
> +        bEscalaY=True
> +        bRotationY=True
> +
> +    if context.scene.imp_sound_to_anim.import_where2== 'imp_w_z':
> +        bEixoZ=True
> +        bEscalaZ=True
> +        bRotationZ=True
> +
> +    if context.scene.imp_sound_to_anim.import_where2== 'imp_w_-x':
> +        bEixoX=True
> +        bEscalaX=True
> +        bRotationX=True
> +        iEixoXneg=-1
> +        iEscalaXneg=-1
> +        iRotationNeg=-1
> +
> +    if context.scene.imp_sound_to_anim.import_where2== 'imp_w_-y':
> +        bEixoY=True
> +        bEscalaY=True
> +        bRotationY=True
> +        iEixoYneg=-1
> +        iRotationNeg=-1
> +        iEscalaYneg=-1
> +
> +    if context.scene.imp_sound_to_anim.import_where2== 'imp_w_-z':
> +        bEixoZ=True
> +        bEscalaZ=True
> +        bRotationZ=True
> +        iEixoZneg=-1
> +        iRotationNeg=-1
> +        iEscalaZneg=-1
> +
> +
> +    # LOCAL 3
> +    if context.scene.imp_sound_to_anim.import_where3== 'imp_w_x':
> +        bEixoX=True
> +        bEscalaX=True
> +        bRotationX=True
> +
> +    if context.scene.imp_sound_to_anim.import_where3== 'imp_w_y':
> +        bEixoY=True
> +        bEscalaY=True
> +        bRotationY=True
> +
> +    if context.scene.imp_sound_to_anim.import_where3== 'imp_w_z':
> +        bEixoZ=True
> +        bEscalaZ=True
> +        bRotationZ=True
> +
> +    if context.scene.imp_sound_to_anim.import_where3== 'imp_w_-x':
> +        bEixoX=True
> +        bEscalaX=True
> +        bRotationX=True
> +        iEixoXneg=-1
> +        iEscalaXneg=-1
> +        iRotationNeg=-1
> +
> +    if context.scene.imp_sound_to_anim.import_where3== 'imp_w_-y':
> +        bEixoY=True
> +        bEscalaY=True
> +        bRotationY=True
> +        iEixoYneg=-1
> +        iRotationNeg=-1
> +        iEscalaYneg=-1
> +
> +    if context.scene.imp_sound_to_anim.import_where3== 'imp_w_-z':
> +        bEixoZ=True
> +        bEscalaZ=True
> +        bRotationZ=True
> +        iEixoZneg=-1
> +        iRotationNeg=-1
> +        iEscalaZneg=-1
> +
> +    iMinBaseX=iMinScaleBaseX=context.scene.imp_sound_to_anim.action_offset_x
> +    iMinBaseY=iMinScaleBaseY=context.scene.imp_sound_to_anim.action_offset_y
> +    iMinBaseZ=iMinScaleBaseZ=context.scene.imp_sound_to_anim.action_offset_z
> +
> +    #escala inicia com 1 e não com zero
> +    iRotationAxisBaseX=context.scene.imp_sound_to_anim.action_offset_x  +1
> +    iRotationAxisBaseY=context.scene.imp_sound_to_anim.action_offset_y  +1
> +    iRotationAxisBaseZ=context.scene.imp_sound_to_anim.action_offset_z  +1
> +
> +    #Added destructive optimizer option - LostLestSignificativeDigit lost/total
> +    iDestructiveOptimizer=context.scene.imp_sound_to_anim.optimization_destructive
> +
> +    bLimitValue=False    #limita ou nao o valor - velocidade
> +
> +    if iMinValue<0: iMinValue=0
> +    if iMaxValue>255: iMaxValue=255
> +    if iMinValue>255: iMinValue=255
> +    if iMaxValue<0: iMaxValue=0
> +    if iMinValue!= 0: bLimitValue= True
> +    if iMaxValue!= 255: bLimitValue= True
> +
> +
> +    print('')
>
> @@ Diff output truncated at 10240 characters. @@
> _______________________________________________
> Bf-extensions-cvs mailing list
> Bf-extensions-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-extensions-cvs


More information about the Bf-extensions-cvs mailing list