Logo
  • Features
  • Educators
  • What's New
  • Blog
  • Showcase
  • About us
  • Contact
Try it now!
Media Utils
Media Utils

Media Utils

Why use Media Utils?

Playing a video in Scratch is impossible. If you want to make an interactive animation or AVG in Scratch, it is also an almost impossible mission. So we built Gandi Media Utilities not only to solve these problems but also to provide a simple audio engine with lazy-load features built in. With Gandi Media Utils, you can:

  • use a video as a sprite
  • lazy-load audio or video and control its playback (reduce first load file size)
  • apply some audio effects to each channel (LPF, reverb, delay)
  • (planned) play music with a sampler or a digital audio instrument

Best Practices

[ will be attached very soon ]

Modules

The extension contains four modules for now. A new digital audio instrument module will be added in the future.

Module
Description
💎 Resource
Load and manage audio and video resources
🎬 Video
Everything about video playback
🎹 Music
Everything about lazy-load audio playback
🎛 Audio FX
A simple audio engine with which you can apply audio effects to each channel
🔬 Experimental
(planned) Everything about digital audio instruments, including samplers, synthesizers, operators, and more
☝
The volume unit in this extension is the decibel (dB). If you want to know why all professional audio software and equipment use dB to measure audio volume, be sure to check this article: Why Use Negative dB for Volume?

Functions and Definitions

💎 Resource

Reload resource list

This button will be placed on the first item in the resource. If you uploaded a video or audio to the Cloud Library, tap Reload lazy audios/videos, and the list will be synced with the cloud library.

Lazy load video or audio

Load a video or audio and assign a name to it in this project.

image
image
☝
The name of the resource must be unique in the project. It will be used as a key or id to load, play, pause, stop and unload resources in the project.

Events when loaded

When a video or audio resource is loaded, the event will be dispatched.

image
image

Dispose of resources

If the resource is not used, you can dispose of it to reduce memory usage.

image

In this case, a video or audio named ‘bgm’ will be unloaded.

Check the status of resources in the project

image

Sometimes your project needs to load more than one resource at the same time. You can use this block to check the loading status.

🎬 Video

Loading status of a video resource

image

In this case, this block returns true if the video named ‘thinkDifferent’ is not loaded.

Properties of a video resource

image

You can get these properties:

Property
Description
Example Value
volume
The current volume of the video resource. The loudness is measured in decibels (dB)
0
current time
The current time in seconds
1.1
duration
The duration of the video
62.5
width
The width of the original video
1280
height
The height of the original video
720

When a video event is received

image

Possible events while a video is playing include:

Event
Description
Duration change
Normally, will be dispatched when a video is loaded.
Progress
Will be dispatched while loading.
Time update
Will be dispatched while playing.
Ended
Will be displaced when a video reached the end.
Play and Pause
Will be dispatched when playing/pausing the video playback
Error
Will be dispatched when an error is encountered

Play a video

image

Play a video at a particular start time. You can choose to loop or stop the playback when the video reaches the end.

☝
You should draw a video before playing. Otherwise, you will only hear the sound of the video.

Stop a video

image

You can choose whether to pause or to stop and remove the video.

When a video is removed, you won’t be able to play it again unless it is reloaded.

Draw a video on a sprite

image

Draw a video on a sprite layer. You should note:

i: x and y are not the positions of the video. They are the offset of the video. For example: You draw a video called thinkDifferent on the current sprite with an offset x: 10, y: 20. The current sprite's position is x: 5, y:6. The video will be placed on x: 10+5, y: 6+20.

ii: The scale of the sprite will affect the video too.

iii: If you leave the width and height options empty, the video will be drawn with its original size.

iv: If you leave the height option empty, the height will be calculated automatically based on the given width and the original video's aspect.

v: If you leave the width option empty, the width will be calculated based on the given height and the original video’s aspect.

iv and v are very useful. NEVER CHANGE THE ASPECT OF AN IMAGE OR A VIDEO is a good rule of thumb for a fine design. My most used code snippet is this:

image

Set a volume

image

0 dB represents setting volume to 100%. -3dB = 50%, -6dB = 25%, -96dB essentially equals 0%, 3dB = 200%.

🎹 Music

Status of an audio

image

You can get these statuses:

  • is not loaded?
  • is loaded?
  • is playing?
  • is paused?
  • is ended?

When status is changed

image

You can listen to the statuses play, end, pause, and resume.

Play an audio

image

Play audio at a start time. When reached the end, loop or stop the audio.

Pause/Resume/Remove an audio

image

The property of an audio

image
Property
Description
Example Value
volume
The current volume of the audio resource. The loudness is measured in decibels (dB)
0
current time
The current time in seconds
1.1
duration
The duration of the audio
62.5

Change the volume

image

Ramp volume of the audio to a destination volume at a specific time. This is very useful to fade in or out audio.

🎛 Audio FX

You can choose which channel to apply audio effects to.

  • Master: all audios in the project will be connected to the master channel;
  • Media Util: all lazy-load video and audio will be connected to it;
  • Scratch: all sound blocks from Scratch.

All available FX

FX
Description
Common Presets
Lowpass Filter (LPF)
LPF is the most useful filter in DJing and audio processing. A cut frequency (in Hz) should be set while using LPF. Set it to 44100 to disable LPF. If you want to emulate a crazy neighbor playing music at midnight, try setting it to 800.
Disable: 44100 Keep a distance: 10000 In the bathroom of your crazy neighbor: 1000 In your bedroom but can hear the sound of a crazy neighbor: 400 It drives you crazy and you put a pillow over your head: 100
Reverb
Reverb can be used to emulate spaces of different sizes. It is the effect of many echoes occurring simultaneously.
Bedroom: 1 Bathroom: 10 Church: 40
Delay
Delay is another type of audio effect that falls under the Time-based category. It is similar to Reverb, but the sound's reflection is clearer.
Normal room: delay 0.1, feedback 0.4 In a valley: delay 0.4, feedback 0.1
Volume
The loudness of the sound.
100% : 0 dB 50%: -3 dB 25%: -6 dB 200%: 3 dB
Pan
The balance of the audio (left or right) [-1,1]
Only left: -1 Only right: 1 Balanced: 0

The blocks:

image
image
image
image
image
💡
Dry/wet is a common term used in audio engineering. It represents what percentage of the sound passes the effector to mix with the original sound. Dry means only the original sound. Wet means only the sound passed through the effector. Setting Dry/Wet to 0 means 100% dry, 0.5 means 50% original mixed with 50% effected, and 1 means 100% from the effector.

🔬 Experimental

We are planning to bring audio instruments, including samplers and synthesizers, to Scratch. Currently, you can play with the following experimental synthesizer:

image

Roadmap and Change Logs

Version
What’s New
1.0
Fixed: - Audio FX won’t affect audio from Scratch - Incorrect video positions Added: - Simple Audio Engine with audio FX and audio instruments - Unlimited tracks of video playback - New resource management
0.1
Init launch - Lazy-load audio playback - Two tracks videos playback

Credit

💡
If you have any questions or suggestions, you can find us in the discord channel: https://discord.gg/U3nyveCvRa
Logo

Designed by 2ndR with love

Discord