How to add audio - script or timeline - best practices

Hi all,

I’m adding audio in ogg format and I thought I could use controllers, states and timeline, but most of the documentation points me towards scripting instead. What is the best practice for setting up audio?

I have an audio file of a person saying different sentences with a break between them. To save on the number of audio files in the project, I’d like to access these different sentences through the timeline (or script if need be): how can I do this, and is this the correct approach?

Thanks in advance!

1 Like

Hello @jolyon,

You may play audios by timeline but the timeline doesn’t mean the audio lenght. If you has an audio that has several parts and needs to be played or manipulate in these parts, what you may do is:

1 - cut the sound with some software like audacity or like this.

2 - you may insert it in a timeline, take his lenght, pass to the timeline and then keep hearing and finding the points you want to stop/play. Every point, you set a label in the timeline and then you program with the label’s events.

The second choice is very boring and hard sometimes (I already done it a few times) then I really recomend you to cut using a software.

att, Higão.

Hi @higor and thanks for your quick reply!

  1. Yes, I thought it would be easier to cut the sound, too, but doesn’t that mean I’ll increase the size of the app because I’ll have multiple sound files?

  2. I’ll take a look at this. Thank you.

1 Like

Hello @jolyon,

About your question…

Is hard to tell you if it’ll increase or not because in times that I’ve done this, the sound was like 100kb and when cutted was 3 parts of 20kb, know? So this will depends of your sound file, software used to cut, the treatments that you have done in the file and etc.

att, Higão.

Very true! Ok, thank you!

1 Like

No worries homie, hope you gotcha! @jolyon

Hi @jolyon,

You can use the video player subsymbol. Instead of using a video link, use an audio file.

Here’s some steps to follow:

  1. Add in the video player from the symbols definitions panel.
  2. Double click on it in the symbol defintions to open it.
  3. Drag in the audio file you want to play to the Media Library.
  4. Enter into the show script.
  5. Go to line 47 and replace sym.export("videoUrl")() with your audio file (drag it from the media library into Z.Video()).
  6. You should end up with something like this: myvid = Z.Video(symbol.mediaFiles.Audio.ogg);
  7. The video player then has a time exported function called time, that you can use to seek to a certain time of the audio
  8. Something like this: Video_Player.nodes.control.time(2000);
  9. If you don’t want the video player to be shown, scale it down to 0,0,0. Turning it’s visibility to false will not work on iOS.

Hope this helps.

George

Interesting approach @George - thanks for that! I will try.

Is there any reason why audio isn’t set up in the same way as animations? After following the animation timeline tutorials I found them easy enough to work with. I was hoping audio files would follow a similar pattern.

Hi @jolyon

A few month ago I did a [Media Player] symbol for a small group of students during a workshop.
You can control it using states, and jump to any time set in milli-seconds. It works for audio and video and has many more features.

2 Likes

Very kind of you, @MrPropre! I’ll have a look and see if I can get it to work with my project! I’ll come back to you. Thanks!

1 Like

Hi again MrPropre,

I’m obviously missing something but I don’t have the Media Player Properties Source, Play/Pause, Loop, Time (in ms), Volume (0=silent - 1=100%), Time display (show current and total time on video) that you mention as States, and I’m a bit confused as to how to set this up?

I’m in the Media Player.zpp > I’ve brought in my .ogg file to the media library > am I supposed to be putting actions on the alpha_video or the .ogg file in the root of the hierarchy, or somewhere else?

Do I need to set up a controller and timeline?

How do I connect everything together?

Bascially I want a 3D character who’s animated and talking to be synced at the same time as the audio because we can’t export an fbx with the audio together. I want to be able to pause the animation or skip it to the next part, and have the audio do the same.

Thank you in advance!

Any further approaches on how to add audio synced with 3D animation? I’ve sent the Zappar team a query too. Thank you!