[request] Java Script For Audio Filesize

What I am looking for is a Javascript that calculates audio filesizes based on information given by a user. I don't consider myself a programmer by any means, that's why I'm making a request for it.

Here's what I had in mind:

Drop-Down Box:
"Bit Depth", choices are "16" (value of 2) and "24" (value of 3)
"Samplerate", choices are 44100, 48000, 88200, 96000, 172000, 192000 (values = choices)

Numerical Input
"Track Hours", value = input x 3600
"Track Minutes", value = input x 60
"Track Seconds", value = input

"Tracks", value = input

Output:
"Filesize per Track" (BitDepth x Samplerate x TrackHours x TrackMinutes x TrackSeconds)
"Total Filesize" (FilesizePerTrack x Tracks)

Now for the Filesize outputs, could you set it up so it knows whether it should use B, KB, MB, or GB?

Thanks to anybody who does this for me.

#182400

You do realise, don't you, that your calculations won't be a very "true" illustration of the filesizes, don't you?

For one thing, if they're compressed, the compression algorithm may cause differences in the tracks based on the content...

#182402

If they're uploading the files, you can use PHP to determine the filesize using the $_FILES['upload_file_name_here']['size'] superglobal. If you want me to explain this in more detail, PM me and I'll post some example code.

#182428

@Stevie BM: No, we only use uncompressed WAV audio at our studio.

@Ludge: We don't upload these files, we just need the tool to make sure the audio session will fit on our hard drives.

#182440

"Filesize per Track" (BitDepth x Samplerate x TrackHours x TrackMinutes x TrackSeconds)

"Total Filesize" (FilesizePerTrack x Tracks)

Do you mean

"Filesize per Track" (BitDepth x Samplerate x (TrackHours + TrackMinutes + TrackSeconds))

"Total Filesize" (FilesizePerTrack x Tracks)

-=edit=- Well, I've gone and written something up, not pretty, but it follows the equations I wrote above (because I think they're more correct, but if I'm wrong there I'll change it back.).

Size Calculator

-=/edit=-

#182454

70 minutes of 16 bits by 44100 samples/sec would give 640 MByte,

exactly what an audio CD would hold, about 2 MBit / second.

Your calculations must be wrong since they yield 4 GB;

I guess you need to reconsider your calculations.

Nice work, though.

#182698

Originally posted by herd@Jun 27 2004, 01:24 PM

70 minutes of 16 bits by 44100 samples/sec would give 640 MByte,

exactly what an audio CD would hold, about 2 MBit / second.

Your calculations must be wrong since they yield 4 GB;

I guess you need to reconsider your calculations.

Nice work, though.

Hey, I just used what the guy gave me. *shrug*

-=edit=- actually, if you've got a better formula, let's hear it. -=edit=-

#182702

Easy up:

Add a division by 8 to the final outcome and hey presto bits/second get bytes on hd...

#182704

Originally posted by herd@Jun 27 2004, 01:38 PM

Easy up:

Add a division by 8 to the final outcome and hey presto bits/second get bytes on hd...

Actually, the one I had on the web already threw a division by eight in there.

I assumed the formula he gave returned bits, so I already divided by eight before displaying the results.

On my form, 70 minutes at 16 bits by 44100 gives an output of 441.59889221191406 MB.. I suppose I could round that off, but meh.

-=edit=- now it rounds to three decimal places -=/edit=-

-=edit again=- okay, I just recorded 60 seconds of audio in Windows Sound Recorder, 16bits, 44100 hz sample rate, and the result is 5.04MB. My form: 0.631 MB. Multiply my form result by 8: 5.04mb. By testing, the result is already in Bytes, and needs not be divided by eight. So, I'm gonna fix that. -=/edit2=-

-=edit3=- What the hey? I added a Channels field, for mono, stereo, or what I've dubbed Stereo+1. :D -=/edit3=-

#182711