How to load audio(sound)

A forum dedicated to George scripting questions
Post Reply
iLLiCiT
Posts: 4
Joined: 05 Oct 2020, 17:45

How to load audio(sound)

Post by iLLiCiT »

Hi, I couldn't figure out how to load audio into TVPaint(TVPaint 11.0.6-32bit) using George script. Is there someone who would help me?

I need to know how to load audio file (From path like: "C:/files/audio/my_file.wav"). I've tried "tv_SoundProjectNew [iPath]" and "tv_SoundClipNew [iPath]" but both does nothing and "result" is empty.
Just want to do what "Load Sound..." action in Clip's sound options does.
Tested george script:
__________________________________
filepath = "C:/files/audio/my_file.wav"
tv_SoundProjectNew filepath
__________________________________

Nice to have would be to load video file(mov/mp4) with audio if has any. I expect that "tv_loadsequence" or "tv_loadimage" can't do that.
User avatar
NathanOtano
Posts: 1208
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: How to load audio(sound)

Post by NathanOtano »

Importing sound with george can be tricky, it involves a lot of data to be stored about the project, framerte, position of the sound etc, and interpreted...
Here is my "import sound" script, you can find it in my storyboard tools (here : viewtopic.php?f=11&t=10376). Hope it helps

If im correct you can import sound with a video file

Code: Select all

tv_undoopenstack
tv_updateundo

tv_projectcurrentframe
curProjectImage=result
		
project_getPath()
ProjectPath = result

FileRequester("Pick a Sound File (mp3)",projectPath," "," ")
SoundFilePath = Result

tv_lockdisplay quiet

IF CMP(SoundFilePath,"cancel")==0
	tv_SoundProjectNew SoundFilePath
	IF result < 0
		tv_unlockdisplay
		PRINT "Failed Importing Sound"
		EXIT
	END
ELSE
	tv_unlockdisplay
	EXIT
END

tv_ProjectInfo
PARSE result q q q q framerate q
offset = curProjectImage/framerate
soundIndex = 0
tv_soundprojectinfo 0 soundIndex
LastSound = result
	
WHILE CMP(LastSound,"-2")==0
	soundIndex = soundIndex + 1
	tv_soundprojectinfo 0 soundIndex
	LastSound = result
END

soundindex = soundindex - 1
tv_soundprojectinfo 0 soundIndex
PARSE result q volume mute fadeIn1 fadeIn2 fadeOut1 fadeOut2 q q q colorIndex

tv_SoundProjectAdjust soundIndex mute volume offset fadeIn1 fadeIn2 fadeOut2 fadeOut1 colorIndex

tv_unlockdisplay
tv_undoclosestack
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
iLLiCiT
Posts: 4
Joined: 05 Oct 2020, 17:45

Re: How to load audio(sound)

Post by iLLiCiT »

> Importing sound with george can be tricky

It is :) . Thank's for advice but it did not help. The issue is that both tv_SoundProjectNew and tv_SoundClipNew do nothing and their result is set to empty string (not an integer) so with the script you gave me it get stuck in endless loop. To catch the situation I would have to modify the check condition to:

Code: Select all

IF CMP(SoundFilePath,"cancel")==0
    tv_SoundProjectNew SoundFilePath
    IF CMP(result,"")==1 || result < 0
        tv_unlockdisplay
        PRINT "Failed Importing Sound"
        EXIT
    END
ELSE
    tv_unlockdisplay
    EXIT
END
But still can't load a sound :(
iLLiCiT
Posts: 4
Joined: 05 Oct 2020, 17:45

Re: How to load audio(sound)

Post by iLLiCiT »

Interesting findings. I tried to load a sound only in TVPaint 11.0.6-32bit. But now I've tried it in TVPaint 11.0.10-64bit where it works. Seems like it does not work in 11.0.6 patch version.
Xavier
Posts: 1855
Joined: 01 Oct 2019, 11:08

Re: How to load audio(sound)

Post by Xavier »

The plugin that import the audio/video data into TVPaint is based on FFmpeg, and we upgraded the version of FFmpeg it uses.

I guess that it may explain :)
User avatar
NathanOtano
Posts: 1208
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: How to load audio(sound)

Post by NathanOtano »

Happy it worked then! :)
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
Post Reply