Play a mp3?
Sculpted Surface? ] Sculpted Tubular ] Sculpted Complex ] Lamp ] Lighting ] Spotlight ] Midi Media ] IFS Edit ] IFS_SOI ] Texture Coords ] Animations ] Animation Chat ] Two Animations ] Door ] Gestures ] Complex Avatar ] Heads ] Proximity Sensor ] Proximity VP unbind ] Switch Node ] Guided Tour ] Beam Slowly ] Stairs? ] Walk ] Duck Shoot ] Navigation Box ] URNs in URLs ] [ Play a mp3? ]

 

Can I play a mp3 file  with Flux Studio?

The answer is yes and no. You can use Flux Studio to build the code that will support a mp3 file and then hand edit the output to make two or three little changes which enable the file to be played.

[NOTE: This example is for an mp3 audio file, but it can also support mp3 video, real audio, mov, avi, gif89a, swf, and many other multimedia formats.]

The basic steps are...

  1. make an object
  2. add a texture to it
  3. make a sound node
  4. make a sensor to trigger off the sound
  5. export the file as ASCII
  6. replace the texture file name with the mp3 file name
  7. delete the dummy/test sound node code
  8. make sure the trigger script refers back to the MovieTexture node
    (the DEF name of the mp3 file line)

The detailed instructions are...

[Advanced users skip down to the mp3 with VCR controls example at the bottom.]

Have an object in the scene that you will not use a texture for. In this simplified example, I will use a box. Add a temporary texture to this object, later we will replace this filename with the mp3 file name.

Add a sound to the scene by hitting the speaker icon and putting in a temporary WAV file so you can test to see that your sensor is working. Later we will delete this entire sound node section (brackets and all).

Add a sensor that will start the sound (touch sensor, proximity sensor, visibility), I will use a touch sensor in this simplified example.

 

mp3_tree.jpg (10822 bytes) The scene tree shows the elements needed.

mp3_texture.jpg (27432 bytes)

Temporary texture (any image will do)

mp3_tempsound.jpg (22607 bytes)

Temporary WAV file (any WAV will do)

mp3_sensor.jpg (25598 bytes)

Touch sensor trigger code, we will edit the script that this makes later.

Test your model to make sure it works, it should ;-)

OK, now to dive into a little code...

Export the VRML97 file as ASCII text so you can edit it.
(File Menu, VRML Export Options, uncheck GZIP; then File, export VRML97 world)

Open your exported file in your favorite text editor (*) and look the lines that match my comments in the A and B files.

[NOTE:     In VRML a comment is anything following a # sign. ]

It should look like this....

mp3_a.txt    mp3_a.wrl

You want to change it so it looks like this...

mp3_b.txt    mp3_b.wrl

So, read my comments in both text files, then change your file A to look like my file B.

Here is a Flux Studio file if you want to examine how the initial file is set up (the A file).

[NOTE: The itspider.wav file is 65KB, the itspider.mp3 file is 3KB; a big difference in download time but it gets across the same message.]

You have greater control over the sound properties is you use both the MovieTexture and the Sound node. Here is an example of VCR style controls for playing, stopping, and pausing an mp3 file.

* For a free text editor you can't beat www.notetab.com if you have $50 in you want the best VRML text editor you need to get VRMLpad ( www.parallelgraphics.com ).

I used Goldwave (the free demo) to read in the sound file and the Lame Encoder (from the same site) to convert it to a very small MP3 file.

Back ] Home ] Up ]