Import the movement of a .wav file to a animation - Engine

Hi vlassius,
I tried your first suggestion and placed the file name in: getInputFilename(“c:\music est beat.wav”, context)
I get the exact same error display.

I tried pasting the:
def execute(self, context):
import os
f= os.path.join(self.properties.directory, self.properties.filename)
f= os.path.normpath(f)
getInputFilename(f, context)
return {‘FINISHED’}

I get same type of errors when I run.
Just a question, each time it displays the:
"Traceback <most recent file>:File “C:\Internet files\Blender\models\untitled.blend/import_sound_to_anim.”,

Why is it calling a “most recent file” and notice the forward slash in the recent file.
It appends the python file name cut short.?

Thanks for the lesson on scripts.:o

************************* Problem Solved to MS Windows users *****************
First, sorry about this. I didn’t expected this kind of error. Like i said, i’m new in Python and Blender so, i don’t know this details yet (weird things)

Linux:
Everything OK, works in any way!!
*You can open and run into the script screen
*You can save in <Blender Dir>/2.53/scripts/addons and use the Add-Ons Panel “Import: Sound to Animation Data”
Tested in Blender: r31604, r31584 and r31541 - Linux 32 bits

MS Windows, well…
The scripting window doesn’t run the script, it gives the error reported by TRock (thanks).
BUT:
You can save the script into “<Blender Dir>/2.53/scripts/addons” and use the Add-Ons Panel “Import: Sound to Animation Data”.
Tested in Blender r31596 - MS Windows Vista 32 bits

To make this script work as a Add-On please, download the version 0.0.3
here

Thank you and please, tell me if there is any more problems (other than some simple errors in terminal, because i’m working on it).

Sorry about the inconvenience!

TRock, i think it mean that the script is running from “untitled.blend”.
I’m really new on all this and have a lot to learn yet.
I did not discover why the error occurs on Blender running in MS Windows. Maybe someday :slight_smile:

Thank you for your patience and help
I hope you enjoy the script :slight_smile:

vlassius, Thank you for your generosity. I feel most people are very patient with this type of development, so any move forward, slow as it may be, is still a move forward.
I installed the add-on and had a quick play. It seem to work, but the wav file was a simple beat, so now I can get to playing. If I see anything I’ll get back. I really wonder how this will play with particles. Lots to try.

Oh yea, If you need something tested under windows, I’m happy to help.
Thanks again.

Wonderful!!
The script has many options (maybe too much) so, please, tell me if you need help!

********************************** NEW VERSION ********************************

Hi, Version 0.0.4 ready to download here

Next versions is planned to be “Beta 0.1”

changes - v0.0.4
new - Added destructive optimizer option
new - Visual Graph to audio in terminal window
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 (into the fps field option) (information from scene)
bug- Display sensitivity +1
bug - Corrected description of the script in add-ons screen

Problems? Suggestions? Please, tell me.

********************************** NEW VERSION ********************************

Hi, Version 0.1 ready to download here
Warning - you will need at least Blender 2.54 r31913

-v0.1 Beta
new - Added support to LAMP object
new - improved work flow
new - check the type of object before show options
bug - option max. and min. values ok now
change- Updated scene properties for changes in property API.

new work flow:
1) Process the sound file
Check on terminal window
If everything is OK, than go to import key frames
otherwise, change options and process the sound file again
2) Click Button to import key frames

Problems? Suggestions? Please, tell me.
thank you

hi,

i’m new to blender and i want to use this skript.
it is working with a build from graphicall (2.54/32430) but i can’t get any movement out from it.

i created a wav file only with a bass drum and a snare.

basically,when i enter a lower max value i’m getting hundreds of keyframes but when i write 255 i only get one.
i tried several values with optimization and base values.

i gave up after hours of trial and error.

when the keyframes are written i only get a straight line in the graph editor,i can see them but they don’t do anything,like i said there is only a stright line with hundrets of keyframes.

can somebody help me?

it would be nice,
thanks,

Sorry about the delay to answer you. I was waiting a email to warn me about any message, and it did not happened.

Please, try to use the default values first.
I suggest to you use the default cube too, just to test and get confortable with the process.
When you import a .wav you can see in the terminal window the audio levels.
For example:
[_________ ] = very low level audio
[++++++++++] = very hight level audio
If you have most [__________ ], increase sensitivity until get most near this: [+++++++ ]

The options min and max values are to cut the max and min values so, just use it after get right values of sensitivity or, let it as default values. Its just a fine tune to be used in the end of the process.

After this, just click “import key frames”

Please, tell me if you get more doubts

Anything that makes animation easier is a big plus. I actually had a problem at first when I was trying to run it in an optimized build. Then I just downloaded a standard build and it worked.

Two questions though.

Can you add an option to set what starting and ending frame the object moves?

Since most people now work with mp3 files, do you think there will ever be a way to do this with an mp3 file instead of the larger wav files?

Thanks again great work!!

Hi,
There is already a “start frame” option.
The end frame is not a option because the sound file defines the total time. I am afraid that the script already has too many options.
Please, how can this option work ? Stop at the end of the frame number and discard the remaining data?

About the mp3 file:
Python (language of the script) does not have a option to work with mp3 directly, so, it turns necessary to run a other program in the middle process (and we get an other place to have problems, because you will need install other libraries or programs to do it)

Maybe the simplest thing to do (and keep the script relatively easy to install) is convert manually the mp3 file to wave file before to process it.

My first propose was to use mp3 too but, i think it is too complicated by now. If anyone has a good idea, please, tell me

Thank you for your message and comments!

The length and end-frame makes sense… Thanks!

The mp3 format is much much smaller. I think they say it is 10 times smaller. Yes I can convert to wave but eventually i really does make sense to make it a bit more complicated and use external libraries.

A 3 minute song might be 3 Megabytes with mp3 or 30 Megabytes with .wav

You did a fantastic job though with this… Great work!

:slight_smile:
Mike

OK I have been playing with the script. When I worked with it the other day I got it to work with a doorbell noise. Today I have a 10 second sample of a song with a drumbeat. The audio graph is always full of [+++++++++++++++++].

The sensitivity value set at 1 doesn’t seem to help it. Do you have a small sample wave I can test out that works good. Can you drop the sensitivity down any more with the python script?

Thanks again :slight_smile:

Yes, that is because you have other instruments playing together. Although it seems a low volume, in general that is because our ear listen like this but in fact, that is as loud as the drumbeat. This happen mainly with very low and very hight frequencies.
You will need to separate the audio you are interested to work. You can use for example “Audacity” to filter the frequencies end other filters to help you.
The best situation is to have just the audio that you are interested to.

There is something that can help a little, is to set the option “acts/s” to 99. This is just a fine tune. Probably will not solve this problem, but can help in some cases.

thank you
Please, tell me if if you still need help

I’ve been busy with other projects. I actually got a moment to test it and I was able to get it to work with converting it to a MONO waveform. I am going to play with it more in the next few days and I will keep you posted.

Thanks :slight_smile:
Mike

A nice blenderartist named cesio published a link to a blender file of a man. It’s available for download on the blenderartists forum website called maxinblender.blend or you can google it. I wanted to start off simple with this man and make his leg move up and down to a sound file. Voice or whatever sound file. I now know how to move an object but how can I move a pose? I can’t figure out how to make a pose attach to an empty object. Would you know how to do that or is there a way to modify the script to move a pose.

Thanks:evilgrin:

Hi, I have no idea :frowning:

Maybe its possible to use a simple object to import the movement from the sound file and after this, export the data to the pose;
Maybe its possible to import the movement to a bone at feet (for example) and use the automatic movement to do the rest
But i really do not know.

If you get a way to do it, please let me now.

I will try something about poses this week, use poses seems to be a nice idea!

thank you

OK here is the trick.

  1. Create a new cube (or any object besides an empty) [since you disabled empty object from moving with sound]

  2. Select the bone you want to move.

  3. Go to “Bone Contraints” button.

  4. Add contraint “Child Of”

  5. Under the “Target” drop down list choose the new object you made

  6. You might have to click the “Set Inverse” button if it cripples your model

  7. Open the python text window and add the python script you made.

  8. Run the python script

  9. Hide the new object you created by putting it in a different layer (unless you want to see this new object moving around with the bone.

  10. Set your script options in the “Objects” button under “Import movement from wav file”. Make sure the settings don’t stretch out the bone too far.

  11. Run it.

Let me know if you ever make a change to the script to work with empties so I don’t have to hide the objects I made that are linked to the bones. :slight_smile:

Thanks again. If I find out any more tricks I’ll keep you posted.

Great!!

I will check it as soon as possible.
I am new in Blender. I just made a few simple animations and i would never discover this!

Please, i have a doubt. Why you did not use the script direct to the bone?

Thanks

Hi hi, works very nice (even I as a newbie could manage it!)
But one has to learn a lot (and to search for a suitable WAV)…
Nice!

An object and another object but now a bone is used for its animation