INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: WAV "encoding" for the UPNP-server  (Read 3046 times)

marin849

  • Recent member
  • *
  • Posts: 12
WAV "encoding" for the UPNP-server
« on: May 23, 2007, 09:40:07 am »

Why not also add an option to always "encode" to wav?
For people who have music stored in hiqh-quality ogg and flac files, it is not ideal to be forced to convert to mp3 when playing on a good stereo system, using the UPNP-server. Just sending uncompressed WAV would be nice, especially if it was done in real-time without decoding and caching the whole track on disk first.
Logged

John Gateley

  • Citizen of the Universe
  • *****
  • Posts: 4957
  • Nice haircut
Re: WAV "encoding" for the UPNP-server
« Reply #1 on: May 23, 2007, 10:32:41 am »

The main problem is that our current WAV encoder is not streaming: it writes the whole file and then seeks back to the beginning to update the header. I'll fix it one day, but it's not a high priority at the moment...

j

marin849

  • Recent member
  • *
  • Posts: 12
Re: WAV "encoding" for the UPNP-server
« Reply #2 on: May 23, 2007, 10:34:21 am »

Ok. But I only have MP3, MPC and OGG as available encoders?
Logged

Raistlin

  • Recent member
  • *
  • Posts: 6
Re: WAV "encoding" for the UPNP-server
« Reply #3 on: May 26, 2007, 04:54:05 pm »

Ok. But I only have MP3, MPC and OGG as available encoders?

Those are the only 3 I see as well.  Are any other formats available?




BTW - I understand it is low priority right now, but I too feel WAV encoding what be a great edition.  I would really love lossless audio support (FLAC to WAC).
Logged

marin849

  • Recent member
  • *
  • Posts: 12
Re: WAV "encoding" for the UPNP-server
« Reply #4 on: May 27, 2007, 01:29:17 am »

Indeed, but without buffering the whole track on disk first.

Wav is a simple format.  To play it, data just has to be copied to the D/A converter (sort of), no advanced DSP needed for decoding. I think that all/most devices that play mp3-files can play wav as well. Therefore, I think it would be really great to have real time decoding and streaming as wav(without a temporary file). It seems over-ambitious to go through the cpu-consuming process of encoding, storing the file on disk and then stream it from there. Especially since it gives less audio quality!
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: WAV "encoding" for the UPNP-server
« Reply #5 on: May 27, 2007, 03:00:13 pm »

Wave may not be as simple format as it seems. Here are a few links to articles that explain the wave container format:
http://ccrma.stanford.edu/CCRMA/Courses/422/projects/WaveFormat/
http://www.borg.com/~jglatt/tech/wave.htm
http://www.sonicspot.com/guide/wavefiles.html
http://www.digitalpreservation.gov/formats/fdd/fdd000001.shtml

The UPNP clients are individual computer devices. MC's server provides an UPNP client a list of the file addresses and some info about the file contents. The client downloads the files, decodes and plays them. If I have understood correctly, wave format is not included in the conversion options because MC would need to write the complete wave file to disk before a client can start downloading it.

It is not possible to just pull decoded PCM audio from the UPNP server. That would need a completely new client/server standard, which would use something like an ethernet version of SPDIF for sending audio data. The client would need to be able to directly control the server and the server would always decode the file before sending the content as PCM audio.
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

marin849

  • Recent member
  • *
  • Posts: 12
Re: WAV "encoding" for the UPNP-server
« Reply #6 on: May 28, 2007, 01:51:25 am »

I think it is very possible! :) The wave-format is not as advanced as it might look.

Some of the parts in the wave-header are static(=easy). We need Numchannels, Samplerate, ByteRate, BitsPersample from the input file, calculate the total size (ChunkSize) and some other values to create the complete header. Chunksize can be calculated after checking the length (not filesize) and the other data of the input file, for safey we can add one second to the length, and provide null-samples at the end if necessary.  Now we can put the WAVE-header together (according to wave-spec) and store in RAM.

Next step is to allocate a buffer to store a few seconds of decoded data, and fill it up with the first seconds of decoded PCM-audio samples from the file to be decoded (Media Center already knows how to do this, since it can play media files to the computer speakers)

Now we can start delivering the "file" to the client!
Send the header and start reading from the buffer of decoded samples. The sound data format in Wave is little endian raw pcm-values = very nice. :)
As the buffer get's empty, we have to continuously fill it with more decoded samples from the input file, as when playing to the computer speakers.

From my point of view, the code needed for all this is already included in Media Center, almost. Since the program can playback media files to the computer speakers, we already have the "read input file and decode in real time to a buffer in memory"-part and the "get length, samplerate and so on from file" and also the UPNP-server can send wave-files. Now we need the short part that calculates the wave-header, and code to bind the parts together.
Logged

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird
Re: WAV "encoding" for the UPNP-server
« Reply #7 on: May 28, 2007, 02:58:03 am »

Chunksize can be calculated after checking the length (not filesize) and the other data of the input file, for safey we can add one second to the length, and provide null-samples at the end if necessary.

As Gateley said, this is what JRiver's wave encoder does not do at the moment. They would need to redesign the encoder.

Quote
Next step is to allocate a buffer to store a few seconds of decoded data, and fill it up with the first seconds of decoded PCM-audio samples from the file to be decoded (Media Center already knows how to do this, since it can play media files to the computer speakers)
Now we can start delivering the "file" to the client!
Send the header and start reading from the buffer of decoded samples. The sound data format in Wave is little endian raw pcm-values = very nice. :)
As the buffer get's empty, we have to continuously fill it with more decoded samples from the input file, as when playing to the computer speakers.

From my point of view, the code needed for all this is already included in Media Center, almost. Since the program can playback media files to the computer speakers, we already have the "read input file and decode in real time to a buffer in memory"-part and the "get length, samplerate and so on from file" and also the UPNP-server can send wave-files. Now we need the short part that calculates the wave-header, and code to bind the parts together.

All UPNP clients use built-in decoders and expect to be able to download complete files from the server provided HTTP address, not to receive decoded PCM data. With the currently available conversion formats MC's UPNP server can emulate this virtually by allowing the download start immediately after the first bytes are encoded (not decoded).
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

marin849

  • Recent member
  • *
  • Posts: 12
Re: WAV "encoding" for the UPNP-server
« Reply #8 on: May 28, 2007, 03:02:37 am »

Yes and yes.
But WAV is not encoded. It is a simple header + decoded PCM-data values. I still don't see any point of writing the whole file to disk first as fast as possible.
Logged
Pages: [1]   Go Up