Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MP3's 1

Status
Not open for further replies.

PhoenixDown

Programmer
Jul 2, 2001
279
CA
Are there any perl scripts made already which can play MP3 files on web pages?

My host doesn't support the MIME command. My MP3's are hosted on my computer. - Go there!
 
There are several perl modules that allow you to edit mp3's (such as the id3 tags), but I don't believe any that let you play them.

I know there is a perl module that allows for you to play WAV files. Don't quote me on this, but I believe the author was updating the module to play mp3's as well.

You can go to to download a module called Win32::Sound. Obviously, this only works on Win32 machines, so if your server is not one, then you are out of luck or will have to find an alternative.

Here is some code that will get you on your way:

[tt]
use Win32::Sound;

# Create the object
$WAV = new Win32::Sound::WaveOut(44100, 8, 2);

$data = "";
$counter = 0;
$increment = 440/44100;

# Generate 44100 samples ( = 1 second)
for $i (1..44100) {

# Calculate the pitch
# (range 0..255 for 8 bits)
$v = sin($counter/2*3.14) * 128 + 128;

# "pack" it twice for left and right
$data .= pack("cc", $v, $v);

$counter += $increment;
}

$WAV->Load($data); # get it
$WAV->Write(); # hear it
1 until $WAV->Status(); # wait for completion
$WAV->Save("sinus.wav"); # write to disk
$WAV->Unload(); # drop it
[/tt]

Hope this helps.
-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
Hmm, you might be able to find a converter that allows you to change the kbps as well, so lower kbps, lower filesize, and lower quality.

Yes, WAV files do tend to get quite large. Which is one of the reasons mp3's have flourished.

I think, and that is I THINK, music match jukebox will allow you to change the kbps. If not, then check and search for mp32wav. I know there are programs out there that let you do it.

Hope this helps.

-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
is host to a program called GoldWave. It is "shareware", but you can use it for about 150 click per session before it starts nagging you to register, then you can save, exit, and reopen it and it won't bug you for another 150 clicks. It has a feature called "resample" that allows you to change the sample rate of wave files and stuff. It will open mp3's and convert them to wave, but you have to get a wav2mp3 converter to convert it back to an mp3.
Steve Kiehl
webmaster@nanovox.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top