Can I encode audio to a compressed format?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Can I encode audio to a compressed format?

Samuel
I have it:

MIC -> WAV

I want to do this:

MIC -> OGG|MP3|AAC

Is it possible?

Tried with different Wav encoding settings.
Whatever comes out to me, it cannot be read from the other side.
Any hints?
Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

fredvs
Administrator
Hello Sam.

Till now, uos can only deal with WAV for encoding.

It is on the TODO list to incode into mp3 or ogg.

But there is lot of programs that can do the conversion, like lame or ffmpeg.

> Tried with different Wav encoding settings.
> Whatever comes out to me, it cannot be read from the other side.

Not sure to understand.
Do you mean that you cannot read the WAV produced?

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

Samuel
No. I just care about size! Because I want to pack it online for in-game voice communication. It is important to me to be able to use the band as economically as possible.
Thanks for the answer. Maybe I could help?
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

fredvs
Administrator
Hello Samuel.

> Maybe I could help?

uos is open-source and, of course, everybody is welcome to make uos better.

About encoding, it would be great if uos could encode in ogg  too.
I have to confess that for this job, I let it do by console-converters.

But, yes, of course, if you want to add a ogg format in uos_AddIntoFile(), it will be welcome.

With libsndfile (that is used by uos), you may encode in ogg (<= size of mp3 with better quality).
http://www.mega-nerd.com/libsndfile/api.html

That should not be very difficult because libsndfile uses the same argument for read and write buffers.

Sadly, I would not be able to work on it now.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

fredvs
Administrator
This post was updated on .
Hello Sam.

OK, for your eyes only, I did add a ogg format in uos_AddIntoFile().

The format for ogg = 3.

So to save into ogg file, you should use this for example:

uos_AddIntoFile(PlayerIndex1,pchar('/home/you/mytest.ogg'), -1, -1, -1, -1, 3);
 
You need last commit of uos for this.

Result of your test are welcome.

[EDIT] Updated demo SimpleRecorder with save to file wav or ogg.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

Samuel
Thanks a lot, I'll see it soon, share the results.
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

Samuel
It works, it works very well.
You just have to set FramesCount to 4096!
When the default is -1, the resulting file is unreadable.

So that's okay:
$ uos_AddIntoFile(xindex,Pchar(FFileName),-1,-1,-1,1024*4,3)

It's so informative.
I keep playing. I want to write to a stream, not a file.
But it's good! Thanks a lot for your time!
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

fredvs
Administrator
Hello Sam.

 > When the default is -1, the resulting file is unreadable.

Yes you have to use the same FramesCount than the one used for the input.

For uos_AddIntoFile(), by default (-1),  the FrameCount = 65536 (the same as uos_AddFromFile).

But for AddFromDevIn() the defaut (-1) is 4096 (to have a better latency), so you need to adapt the framescount.

>  I want to write to a stream, not a file.

Not sure to understand, do you want the same for uos_AddIntoMemoryStream()?

Fre;D

Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

fredvs
Administrator
This post was updated on .
Hello Sam.

> >  I want to write to a stream, not a file.

In last commit, added "AudioFormat" parameter in uos_AddIntoMemoryStream().
You can choose now or wav or ogg format.

Example to save the memory-stream as ogg format: (last parameter: 0=wav, 1=ogg)

 uos_AddIntoMemoryStream(PlayerIndex1,thememorystream,-1,-1,-1,1024,1);

I hope it is what you want.

The demo ConsolePlayMemorystream.pas is updated.
It shows how to save into a ogg-memorystream and use it later.
 
Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Can I encode audio to a compressed format?

Samuel
Thanks!
I'll see, the topic is hot as usual!