Sound buffering

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

Sound buffering

Samuel
It's code:

InIndex := uos_AddFromMemoryStream(FDevIndex,aMemoryStream,-1,-1,-1,-1);
uos_AddIntoDevOut(FDevIndex,-1,-1,uos_InputGetSampleRate(FDevIndex,InIndex),uos_InputGetChannels(FDevIndex,InIndex),-1,-1,-1);
uos_InputAddDSP1ChanTo2Chan(FDevIndex,InIndex);
uos_InputAddDSPVolume(FDevIndex,InIndex,1,1);
uos_InputSetDSPVolume(FDevIndex,InIndex,a/100,a/100,true); /// Set volume
if FMeter then uos_InputSetLevelEnable(FDevIndex,InIndex,1);
if FPosition then uos_InputSetPositionEnable(FDevIndex,InIndex,1);
if FCalcLoop then uos_LoopProcIn(FDevIndex,InIndex,@LoopPlayer);
uos_EndProc(FDevIndex,@ClosePlayer);
uos_Play(FDevIndex);  /////// everything is ready to play...

How do you change it to add sound caching?

Unfortunately, I do other things in the program, and sometimes I have detentions. That's why I want to add caching, would someone suggest in the subject? Thanks!

ps. I've been fighting this since yesterday ...
Reply | Threaded
Open this post in threaded view
|

Re: Sound buffering

fredvs
Administrator
Hello Samuel.

>How do you change it to add sound caching?

Sorry but I do not understand, do you mean how to get sound from input--device?
If so, you may take a look at SimpeRecorder demo.

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

Re: Sound buffering

fredvs
Administrator
Re-hello.

Could you please explain what you want to realize?

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

Re: Sound buffering

Samuel
I solved and works. Caching was not needed, it was a mistake to use this line of code:

       (...)    uos_LoopProcIn(FDevIndex,InIndex,@LoopPlayer);     (...)

And use from your own timer :)

What did I need it for? I wrote an application to help the radio community. They had their radio, chat ...
So I wrote an application to listen to the radio, chat client and mp3 player, ogg etc. Everything in one application.

I used mplayer to receive the radio. I wrote the chat client from the beginning, I used the code that someone wrote for websockets. A player on UOS.

And there was a problem, some things in the chat meant that UOS was prune. I thought to add this buffering ... But no! It was enough to cancel the loop and add the own timer code.

Thanks for the help! Greetings!
Reply | Threaded
Open this post in threaded view
|

Re: Sound buffering

fredvs
Administrator
Hello Samuel.

Great that you did find a solution.

May I ask you what widget-set are you using (LCL, fpGUI, MSEgui, ...) and what OS (Linux, Windows, FreeBSD,..) ?

Thanks.

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

Re: Sound buffering

Samuel
Lazarus v2.0.0./Gtk2 Linux and Windows. I'm sitting on Linux, and people are on Windows.

If someone wants to download and have fun, here's the link:

https://sourceforge.net/projects/radio-player-forte-plus/files/

The program also responds in English, thanks for your help and best regards!
Reply | Threaded
Open this post in threaded view
|

Re: Sound buffering

fredvs
Administrator
This post was updated on .
Hello Samuel.

Wow.

Fre;D

 
Reply | Threaded
Open this post in threaded view
|

Re: Sound buffering

fredvs
Administrator
This post was updated on .
Hello Samuel.

Here some tips:

- For compilation "a la carte": you may adapt define.inc.
  In your case, if you only want to do radio-web streaming, you will only need to uncomment this in define.inc:

  {$DEFINE portaudio} // uncomment to enable portaudio In/Out sound port
  {$DEFINE mpg123} // uncomment to enable mpg123 (mp3 audio file)
  {$DEFINE webstream} // uncomment to enable Internet Audio Streaming

  All others may be commented.

  If you do this, only uos.pas, uos_flat.pas, uos_portaudio.pas and uos_mpg123.pas will be used.

- Load only the libraries you need and add only those in your release:, PortAudio and mpg123:
  uos_LoadLib(Pchar(PA_FileName), nil, Pchar(MP_FileName), nil, nil, nil);

- If the libraries are already on the system, you may use:
  uos_LoadLib('system', nil, 'system', nil, nil, nil);

  Or if you want to give to the user the possibility to use the libraries installed on the system:

  if uos_LoadLib('system', nil, 'system', nil, nil, nil) < 0 then // try to use libraries from system
  uos_LoadLib(Pchar(PA_FileName), nil, Pchar(MP_FileName), nil, nil, nil); // if not use libraries from your release



Fe;D




Reply | Threaded
Open this post in threaded view
|

Re: Sound buffering

Samuel
Thanks, that's how I did it and it works.
My app is growing, I use a lot of different technologies in it. It's quite a challenge for me right now.
Thanks!