Pages: 1 [2] 3   Go Down
Author Topic: How to play Raw audio?  (Read 3534 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should explain to prevent confusion.  The audio files are generated in real time.  I cannot convert them to MP3 or any arbitrary format in advance thru a manual process because the data is constantly changing.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Oregon, USA
Offline Offline
Edison Member
*
Karma: 69
Posts: 2366
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you mean you are constantly uploading the audio to the website, like a webcam?
Logged

"It seems to run on some form of electricity"

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems many browsers support HTML5 Audio?  But not IE9
http://blog.deepbluesky.com/blog/-/browser-support-for-css3-and-html5_72/

Here's how to test yours:
http://fmbip.com/
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Like a Webcam without Video!  Except only when triggered by an event.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should explain to prevent confusion.  The audio files are generated in real time.  I cannot convert them to MP3 or any arbitrary format in advance thru a manual process because the data is constantly changing.

Well there is real time and nearly realtime (delayed by perhaps a few hundred milliseconds).
Keep in mind that if you upload the wav file (already with header added by arduino) to the servers script, it will take that server very little time to make that file in wav available and automatically convert that wav to mp3 and make that available as well.

You also mention that the uploading is only done when triggered by an event, so it's not as if it's like streaming mpeg video like in a IPTV setup and presumably you have a few hundred milliseconds to spare between events that trigger the upload.
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should say near real time.  It will take a few seconds after the recording is complete before it can finish sending it to the server, then to the browser.  I don't see the need for MP3 conversion, since I plan to use uLaw in addition to PCM.  Unless it's simple.  Would you be able to help me when I get to that point?  CGI or Javascript?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can the HTML5 Audio object play a uLaw encoded WAV file?  On iPhone? 
Then I'd only need 1 file format...
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Would you be able to help me when I get to that point?  CGI or Javascript?

Sure, I prefer Perl over php.
I suggest going for CGI as then it's run server side and you are not relying on the users device having to support js.

Quote
Can the HTML5 Audio object play a uLaw encoded WAV file?  On iPhone?
Can't say for sure, but my guess would be no, probably only uncompressed PCM.

EDIT:

See here:
https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats
Then scroll down to Browser compatibility then click on the tables tabs Desktop or Mobile to check compatibility.
« Last Edit: November 12, 2013, 03:32:54 pm by UnoDueTre » Logged

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to use .wav headers, you can't upload "in real-time" as in "streaming".  The wave file header has a couple fields that require the data size to be known in advance.  That means you either have to process the entirety of the audio on the Arduino so you can add the header and upload the whole file at once, or you have to have random access to the file on your server, so you can stream the data, then go back and modify the header once the recording ends.  Or you have to record fixed-length chunks.

In terms of codec support, there are usually media plugins that can handle any common format, whether the browser natively supports it or not.  If you have QuickTime or WMP or VLC plugins installed and enabled, you shouldn't have to concern yourself with whether the browser understands that format.  Test and verify of course.

According to this page, these two voice sample formats are supported by the wave container:

Code:
0x0006 WAVE_FORMAT_ALAW 8-bit ITU-T G.711 A-law
0x0007 WAVE_FORMAT_MULAW 8-bit ITU-T G.711 µ-law

Others can be, with the extensible format header.
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

According to your link PCM in WAV is the only format that works on 3 of the 5 browsers completely including iPhone Safari.  Those are my requirements.  If I want to include all browsers I have to use a Flash Player in addition, since iPhones don't do Flash.  This will be easy since I already have the AU/uLaw file data.  The header is only a few constant bytes which do not depend on length.  I will process the whole file at once.  uLaw does not work together with HTML5 audio in WAV.  PCM is required for 3 out of 5 browser compatibility.  So I will create 2 files.  PCM and AU.  Perhaps I will truncate the WAV data to 8 bits while the uLaw stays at 10 for better quality.  The file sizes will then be the same.  If I choose I can archive the uLaw data only.  So much work to do...
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Read it again SirNick.  Fixed length files!  That's a grand idea!  Then I can start streaming with the constant WAV header.  Since I already know the length I don't have to go back to fix it.  No random access or CGI needed.  All the processing is done on the microcontroller.  I like Simple.  Much less RAM needed.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to use .wav headers, you can't upload "in real-time" as in "streaming".  The wave file header has a couple fields that require the data size to be known in advance.  That means you either have to process the entirety of the audio on the Arduino so you can add the header and upload the whole file at once, or you have to have random access to the file on your server, so you can stream the data, then go back and modify the header once the recording ends.  Or you have to record fixed-length chunks.

Very true, wav is not streaming format.
What I advised sbright33 to do is get either the Arduino to add the required header fields before hand (the easiest method) or upload to the server and the server will add the header and/or also convert to a different format.
Either way, all the data including the header will be present and thus the user can download the sound file.

Quote
In terms of codec support, there are usually media plugins that can handle any common format, whether the browser natively supports it or not.  If you have QuickTime or WMP or VLC plugins installed and enabled, you shouldn't have to concern yourself with whether the browser understands that format.  Test and verify of course.

Yes plug-ins are available but not always for different platforms, plus Quicktime has become such bloatware lately that it's best avoided.

Quote
According to this page, these two voice sample formats are supported by the wave container:

Code:
0x0006 WAVE_FORMAT_ALAW 8-bit ITU-T G.711 A-law
0x0007 WAVE_FORMAT_MULAW 8-bit ITU-T G.711 µ-law

Others can be, with the extensible format header.

Does that also apply to HTMl 5, I suspect not.
Keep in mind that the whole idea about the <video> and <audio> tags of html 5 is to support them natively and not via plug-ins.
« Last Edit: November 12, 2013, 05:32:36 pm by UnoDueTre » Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No random access or CGI needed.

Well you will still need CGI depending on how you want to upload the file to the server.
This is pretty simple as most hosting providers already have either Perl or PHP available and uploading scripts are common.
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe I only need one line of PHP:
file_put_contents('test.WAV', file_get_contents('php://input'));
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Sr. Member
****
Karma: 7
Posts: 468
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Technically yes, but you may want to consider things like adding a password and  limiting the allowable file size.
Keep in mind that the password will be sent in the clear (i.e. no https) so is not resistant to "man in the middle attack" but will stop casual unwanted uploads by others.
Since you will be adding the header before hand, it makes sense to do some basic checking in the script to ensure the file being uploaded is at least a wav file.
Logged

Pages: 1 [2] 3   Go Up
Jump to: