Killersound Tip: Optimize digital audio for Flash Lite

Source: Internet
Author: User
Tags contains file size window zip truncated advantage
Skills | optimization

Like Macromedia Flash has changed the way we experience the Web, Macromedia Flash Lite has the same effect on mobile devices. Sound effects are part of this rich experience. In fact, sound is an integral part of any mobile device, providing warnings, ringtones, audio prompts, and background music for a variety of entertainment uses. In this article, I'll introduce you to the Killersound tip-an innovative way to use sound in Flash Lite 1.1, which is also useful for using Flash on your desktop. With this tip, you can reduce the file size of digital audio by up to 70%. It also offers a variety of auditory experiences, not just simple audio playback. This technique is especially useful for products that require longer background music, such as games. In fact, the longer you need the music, the more you can benefit from this technique.

Please note that this tutorial uses a digital audio file (WAV or MP3) instead of a MIDI file. Not all mobile devices with Flash capabilities support digital audio because of the file size of the digital audio and the higher processing power requirements. However, by the time this article is published, it is likely that most new mobile devices will support digital audio by using better hardware (speakers), more memory, and faster processors. At the same time, I am sure that the next version of Flash Lite will use this progressively improved technology to deliver a richer mobile experience.

  tutorials and sample files: Layering_audio.zip (ZIP, 3.6 MB)

  Prerequisite Knowledge: medium flash Knowledge, especially the use of audio in flash knowledge, will help.

MIDI has been the standard sound format for mobile devices so far. Although this format is simple, it is very limited in sound quality and the number and type of sound effects that can be produced. The sound effects generated via MIDI depend on the waveform sheet that is part of the mobile device chip. Unlike digital audio, the MIDI file does not contain any sound, it contains a set of instructions to trigger the sound effects on the phone's chip. In contrast, the digital audio contains the sound itself, which can be broadcast, voice, or vibrating sound. The sound quality of a digital audio depends on the sample rate recorded or stored. Most of us are familiar with the MP3 digital audio format. The higher the bit rate or sample rate, the better the sound quality. However, a higher bit rate also means that the file is larger.

The techniques described in this article relate to the layering of digital audio files that can be used by digital musicians. In Flash, you can reuse visual elements to avoid increasing the exported SWF movie, and you can do this for audio as well. By importing individual elements or pieces of music (bass, drums, etc.), placing them on different layers, and using the sound tools in Flash, you can create the illusion of a musical transformation. This technique also gives the designer the freedom and flexibility to combine music to match the visual elements in the product. To take advantage of this tip, you must have all the elements in the music you want to use. Currently, you can use music that has been broken down into components by licensing, or you can use popular software products to create your own music.

First download and expand the layering_audio.zip archive file that is matched with this tutorial. The file contains a FLA file, two SWF files, and a file named Silent.wav.

Open the C0064.fla file. On the Stage is the image shown in Figure 1. The paper consists of four parts-violin, cello, guitar and piano. If you enter the Library, you can listen to each section individually. All four sections are in a folder named musical Elements. In this tutorial, you will make a Flash Lite SWF movie and run it on the Nokia 6600 phone.

Note: You can get the latest preconfigured templates for various mobile devices from the David mannl ' s Flash lite* Web site. These templates have been set to the correct screen size.

Figure 1:c0064.fla file contains four sections.

Each section is individually recorded and optimized and imported into Flash as a separate sound file. In order for the sound to play correctly on its own layer and to be synthesized with other sound effects, all sound files must have the same length or the same proportions as each other. In this case, all four parts have the same length. Color blocks represent instances in which these parts play on the timeline. If you run a movie in a Flash application, you will hear music as you play the parts.

Figure 2 shows the Flash timeline. Each section has its own layer, with the exception of the silent layer, the other layers start at the same keyframe (frame 16th), which will be discussed later. All musical elements are important at the beginning of the same keyframe. This is explained in detail later.

Figure 2: On the timeline, each section has its own layer and starts the same keyframe.

When exporting to Flash Lite, it is best not to start the sound immediately, and you should provide multiple blank frames to cache the data. Some slow-moving devices begin to display content for a second or so, so if the audio starts too fast, the start section may be truncated.

Set up and edit sound seal decorations

Now, go to the Strings-event layer and click on the 16th frame of the embedded sound. In the Frame Properties window, you can see the accompanying sound name C0064strings.wav, which is repeated 10 times. Click the Edit button to open the Edit Envelope window. Click the Frames button (lower right) to convert the timeline tick from seconds to frames. (Use the Zoom button at the bottom of the window) to shrink until you see the six-pack decorations applied to this section (see Figure 3).

Figure 3: You can change the sound volume by applying a wrapper point (small square).

The package point that appears as a small square in the sound window is the volume point. You can click or drag these points to create a volume effect. You can adjust the appropriate volume levels for each sound layer to get the best synthetic volume. The two windows in the Sound window represent the left and right channels. Unless you want to create a special effect such as sound drift, be sure to mirror the action in two windows.

You can see that after the C0064strings.wav loop is played two times, a quick fade is made using the encapsulation point. This section remains silent until the fifth instance or loop is played. Enlarge the point at the beginning of the fifth instance to the maximum (see Figure 4). This should be in the NO. 399 frame attachment. You can switch between sampling view and time view (two buttons to the right of the zoom button at the bottom of the window). The encapsulation point is set at the beginning of the fifth instance or loop. When using this technique, you need to achieve this precision to ensure smooth synthesis.

Figure 4: Zoom to maximum to accurately manipulate the package point.

Now, let's look at the other layers and how they are applied to the encapsulation points. For example, the parts of the violin are not set to the maximum, because you do not want the sound of the violin to be more distracting. This synthesis is only one of many possibilities. For example, you can choose to start the music with only the guitar, then join the cello section, and so on. The more parts in the synthesis, the more possibilities there is. However, there is a limit to the number of layers of sound. I recommend that you use more than four to five layers in the Flash Lite. As technology advances, mobile devices and Flash Lite players are more robust, and this limitation may no longer exist. It should also be remembered that at the moment, for any sound in a specific keyframe, you can only apply up to eight seals-so be smart and creative to use them. Of course, if you start a new instance in a new keyframe, you have eight new encapsulation points.

Stream and Event sounds

As you can see, the sync settings for all layers (except the silent layer) are Event. For Event,flash Lite individually export and read individual sound layers. The advantage of this approach is that Flash Lite the sound file as an instance. When Flash Lite loads a single component or sound file, it works the same way as the graphic. Therefore, no matter how many times a sound file is cycled in its own layer, Flash Lite does not use the extra file space to loop the sound file around the timeline, nor does it bind the sound layer to the animation. When you use the Event Sync setting, the sound file runs independently of the graphics.

Sometimes a problem occurs if the device's processor speed is slow. If there is not enough memory, Flash Lite will not be able to read all the layers in one frame at the same time. This may cause the sound layer to not sync with each other. To solve this problem, we use a very small silent audio file to place the player in streaming mode at the beginning of the music, which is enough to allow the event sound to start playing. You can see that the silent layer, which is set to stream, uses this tiny sound and starts before other layers of music. Starting music with a sound that is set to stream keeps the layers synchronized. I have provided this file separately (silent.wav) in case you need to use it in the future.

If you want to use the stream as the synchronization setting for all layered sounds, the animation is bound to the timeline. With this setting, Flash Lite exports and reads all sounds as a single sound file on a single channel. This locks all sound files in sync and therefore no longer requires silent sound effects. However, this setting does not have the advantage of using a component as a looping instance to produce a file. At the same time, when using stream, as long as there are enough frames in the movie, the concert runs. Unlike event settings, music set by stream will be truncated if there is not enough frames to contain the audio or if an action stops the movie from playing.

Compression

For compression, you can use global compression settings, or you can set up a separate compression for each sound file. A low frequency sound, such as a cello sound, can be a very large compression ratio. Other such as drums, if excessively compressed, may be truncated. The advantage of setting up the compression alone is that you can reduce the file size by compressing the larger portion, while setting a smaller compression ratio for the more sensitive parts of the fidelity, resulting in better sound quality. To set up compression for a single file, locate a single file in the Library window, right-click on the file, and then compress the settings in the Export Settings dialog box.

Global settings compression may be easier depending on file size limitations (see Figure 5). Note that the stream sound effect (silent.wav) compression is set to the maximum possible compression, because the sound is silent and the file can be as small as possible.

Figure 5: You can set the global compression when exporting the SWF file.

Keep in mind that the sound effects you make are likely to be played through tiny, single frequency speakers, so the sound quality is limited by the speakers. Ideally, you'd better use the actual device for testing. However, I found ADPCM, 11kHz, 4 bit, Mono such a set of global export settings can be a good result in most cases. For tiny speakers, it balances the sound quality with the smallest file size. Note that using Flash Lite and this tip, ADPCM is the only export format to achieve seamless looping playback. Desktop Flash products use MP3 to get a higher compression ratio, but flash Lite can not play on a mobile device if exported using MP3 compression. Flash Lite If you use MP3 compression, you will leave a gap at each loop point, and there will be a second interval when the sound loop plays. Playing the SWF file on the desktop does not have this problem, and will appear when it is loaded on the mobile device.

Results

If you export the FLA file using the compression settings mentioned earlier (ADPCM, 11kHz, 4 bit), the file size will be the same as the SWF file named c0064_4_adpcm11-4.swf. Another SWF movie attached to this article, c0064_mix_adpcm11-4.swf, uses the same compression settings to play the same music, but does not use layering techniques. Instead, it uses a single static sound file. All two files contain music that plays for about 48 seconds. But the difference in size is great:

C0064_4_ADPCM11-4.SWF: This file contains four sections of the hierarchy. Each part length is 4.8 seconds, so the audio length of the file is 19.2 seconds (4 x 4.8). The size of the exported file is 108K.

C0064_MIX_ADPCM11-4.SWF: This file uses a single piece of music, about 48 seconds in length. The size of the exported file is 260K.
As you can see, in this example, using the Killersound layering technique saves about 60% of the file size.

Summary

If you use the techniques shown in this article for Macromedia Flash Lite, you will have a lot of flexibility and can significantly reduce the file size of the SWF. The basic concept is that all kinds of control over music can be achieved by importing different elements of music into different layers and manipulating them in each layer. This allows you to tune your music in the way you like, and avoid using a single, static audio. The resulting track file is small in size and contains multiple looping elements that are deliberately muted and muted at several points.

You can find more tutorials and information on the killersound* Web site that apply to both Macromedia Flash Lite and Flash.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.