Hi
Is there a way to get the volume and peak frequency at a given point in a playing audio stream. I have looked at the wave example, but this does a volume only on the whole file, and if the file is large it can take some time, I am trying to create the image in a thread; so that the mp3 can be playing, and the image generated in the background; this way the resolution of the image can be larger than visible. Hope you understand. Also is there similar Right and Left Levels available for the Output. and levels for each eq band on a pre and post eq basis? Sorry for lots of questions. |
Administrator
|
Hello.
> Is there a way to get the volume and peak frequency at a given point in a playing audio stream. i did not try, maybe using a other thread of the song with uos_seek() for the give point + InputGetLevelLeft() + InputGetLevelRight() + uos_stop()... > I am trying to create the image in a thread; so that the mp3 can be playing, and the image generated in the background; this way the resolution of the image can be larger than visible. Huh, something like the players of StumPract (https://github.com/fredvs/strumpract) ? Fre;D |
Hi
Thanks for your reply. I have experimented with seek and inputgetlevel, this will work for the vu level, I was also after finding the peak frequency at the same given point, this is so the generated wave can show the volume and the peak frequency simultaneously. The image that I will be creating will be 8192px wide by 512pxhigh, this allows for a good enough resolution to allow realtime zooming and scrolling of the wave when playing. The thread can create this, it takes some time, but the thread can also then allow an even higher resolution from a point to allow further detailed analysis to a m/s resolution when playing is paused. Vurrently my routine creates the wave directly on a timage canvas; which has many advantages and also saves the completed image to a file of same name as input source, so as to recall if it has already been created. The realtime eq freq levels is for an equalizer, that has vu meters by each fader showing the vu of both l/r channels of the mid point frequency of the band the fader is adjusting. Can an Equalizer be created for pre and post effects, ie eq the input source before any effects, and then have a post equalizer to fine tweek the output? |
Administrator
|
Hello.
> Can an Equalizer be created for pre and post effects, ie eq the input source before any effects, and then have a post equalizer to fine tweek the output? Sorry, but I am not sure to understand what you want. In theory, you may apply how many DSP's (including equalizer) you want, only you hardware is the limit. Fre;D |
Hi
Can I have an equalizer on the Output side. I would need to EQ the input, apply effects, then EQ the ouput Pre EQ->Effects->Post EQ ( to remove hi/lo etc from effects added). How can I find out the System Main Out Level, so that I can apply this to the VU Levels. ie if I set Windows Volume to 50% then I need a way to read this value so that I can calculate the Output Levels.. I have look through the uos.pas file; are there other functions that are not in this file. Thanks |
ps
If I open one app that uses uos which accesses its own dlls in a seperate location and play music If I then open Simple Player then the audio from first app stops. How do I stop this?? |
Administrator
|
In reply to this post by ic
Hello.
> Can I have an equalizer on the Output side. You may apply effects with InputAddDSP() and/or OutputAddDSP(). >How can I find out the System Main Out Level Do you mean the general volume of the OS ? No, uos does not deal this (at the moment). You should use the build-in command of the Windows audio-driver. > If I then open Simple Player then the audio from first app stops. With what OS (Windows, Unix, Mac) ? I cannot reproduce this, could you give a demo/example ? Fre;D |
Administrator
|
In reply to this post by ic
>If I open one app that uses uos which accesses its own dlls in a seperate location and play music
> If I then open Simple Player then the audio from first app stops. Re-hello. I did try with Unix and Windows, but cannot reproduce this. Could you give also the steps how to reproduce it ? Thanks. |
Hi
I have played with the add dsp feature, and these work. But I have not worked out how I can get/set eq on both the pre and post effects If I set levels to uos_InputSetLevelEnable (playerindex,inputindex,1) for pre dsp effects how would I set uos_InputSetLevelEnable(...,2) for post dsp on the same player,index? If I try, this overrides the first setting. video showing sound issue.. https://www.dropbox.com/s/hexkwjf2uimm8dk/uos_sound_cut.mp4?dl=0 windows 10 64, 1803 Is there a way to make the uos_LoopProcIn more frequent? It seems to lag. If I create a thread that gets the l/r levels at 10ms then it's more in sync with the music playing. It's a shame it has no means of get/set system volume, as my apps go full svreen, so no minimize and no status bar; I would need to exit this mode to get access to windows master volume. It would be nice to have these available. |
"Is there a way to make the uos_LoopProcIn more frequent?" If I set the framcount to 8192 instead of -1 then it's much more responsive; I have tried lower figures but this increaes cpu usage; 8192 seems fine for my needs :) Input_Index := uos_AddFromFile(Player_Index, pchar(audio_folder+filename), -1, sample_format, 8192); |
Administrator
|
In reply to this post by ic
> it's a shame it has no means of get/set system volume...
It is a shame that not all OS use the same code ! To change sound volume in Windows, use WaveOutSetVolume function. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence. uses mmsystem; procedure TForm1.Button1Click(Sender: TObject); var MyWaveOutCaps: TWaveOutCaps; Volume: Integer; begin Volume:=Scrollbar1.Position; if WaveOutGetDevCaps( WAVE_MAPPER, @MyWaveOutCaps, sizeof(MyWaveOutCaps))=MMSYSERR_NOERROR then WaveOutSetVolume(WAVE_MAPPER, MakeLong(Volume, Volume)); end; About your video, on my Lenovo + Win10 ---> sorry, I cannot reproduce it. Fre;D |
This post was updated on .
Hi
The video, I get the same on 2 laptops, my developer desktop, and my DAW workstation, so something odd. Question I have setup a 10 band EQ and when I adjust the Equalizer and let it just play the music, more often than not after a couple of minutes it crashes and points to uos.pas line 3646 with erange error; my frame count is set to 8192, could this be the issue? case Data.SampleFormat of 2: begin if ifbuf = True then ------> ps^[i] := trunc((res * 1) + (res2 * fft.gain)) else ps2^[i] := trunc((res * 1) + (res2 * fft.gain)); end; 1: Question 2 i am having a problem trying to getthe values of the filters into array. The code below plays the song, but nothing is in the Level_Array ? Any ideas as to what could be wrong with my code? The Eq_Index Array is populated with 0..9 and When I change the equalizer the sound is changing, so the Filters Must be set and working.. Level_Array:array of cfloat; ...... Player_Index:=0; if uos_CreatePlayer(Player_Index) then begin Input_Index:=-1; Input_Index :=uos_AddFromFile(Player_Index, pchar(audio_folder+'\rhapsody.mp3'), -1, sample_format, audio_frame_count);//-1); sample_rate:=uos_InputGetSampleRate(Player_Index, Input_Index); channels:=uos_InputGetChannels(Player_Index, Input_Index); Output_Index :=uos_AddIntoDevOut(Player_Index, -1, -1, sample_rate,channels,sample_format, -1, -1); uos_InputSetLevelEnable(Player_Index,Input_Index, 2) ; uos_InputSetPositionEnable(Player_Index, Input_Index, 1) ; uos_AddIntoDevOut(Player_Index ); uos_EndProc(Player_Index, @ClosePlayer1); uos_LoopProcOut(Player_Index,Output_Index,@LoopProcOutputPlayer1); uos_BeginProc(Player_Index, @BeginPlayer1); uos_LoopProcIn(Player_Index, Input_Index, @LoopProcPlayer1); //setup equalizer For I:=1 to 10 do EQ_Index[I]:= uos_InputAddFilter(Player_Index, Input_Index, Equalizer_Bands[i].lo_freq,Equalizer_Bands[i].hi_freq, 1, 1, true, nil); uos_Play(Player_Index); sleep(2000); Level_Array:=uos_InputFiltersGetLevelArray(Player_Index,Input_Index); |
Administrator
|
> The video, I get the same on 2 laptops, my developer desktop, and my DAW workstation, so something odd.
What OS: 32 or 64 bit ? i did try on Windows 10 64 bit with 2X uos-SimplePlayer 32 + StrumPract 32, all are playing together ok and no stop if a new instance of a uos-demo is loaded. Sorry, I do not have any screen recorder installed, you have to trust me. For the 2 other questions, i will study it asap, I am over-booked this week. At first look: Level_Array gives a array of level of volume, not of level of filter. Could it be possible to give a zip-demo of what you try to do (in this forum-page, click on "More" + "Upload a file")? Fre;D |
Hi
i have created a minimized simple project; this creates a graphic using progressbar of the filter levels, which works for while then crashes out. It uses same folder structure as uos examples; so expects the dlls and extra sources etc. i use an mp3 of rhapsody, but all other I have test Bat out of hell for example also give a sigsev or runerrro 204 after playing for a minute or two. when running its using just under 1% of cpu resources. Extrnal SIGSEV in debug and release mode. points to uos.pas line 3705 if ifbuf = false then begin data.levelfilters := data.levelfilters + '%'+ DSPLevelString(fft.VirtualBuffer, Data.SampleFormat, data.Ratio, levelleft, levelright) ; setlength(Data.levelfiltersar,length(Data.levelfiltersar)+1); ---->Data.levelfiltersar[length(Data.levelfiltersar)-1] := levelleft; setlength(Data.levelfiltersar,length(Data.levelfiltersar)+1); Data.levelfiltersar[length(Data.levelfiltersar)-1] := levelright; end; runerror 204 points to uos.pas function Tuos_Player.InputFiltersGetLevelArray(InputIndex: cint32): TDArFloat; // InputIndex : InputIndex of existing input // result : array of float of each filter. //in format levelfilter0left,levelfilter0right,levelfilter1left,levelfilter2right,... begin -----> if (Status > 0) and (isAssigned = True) then Result := StreamIn[InputIndex].data.Levelfiltersar; end; Hope that helps. ps Runing latest win 10 64 (1803) on all systems. uos_filter.zip |
Administrator
|
Hello.
OK, I will (try to) find some time this week-end to check your demo. Write you later. Fre;D |
Ok that fine.
Not sure if you can test/confirm this finding.. if I compile for 64bit and run with 64bit dll, the errors vanish. Wondering if latest Windows 10-64 release is having issues running 32bit dll's. Just a thought. i have been playing further and have done something, which hopefuly you can say you need to set this/that. I have managed to get it display the EQ band levels, and I can change the individual levels of the EQ, the bars confirm this as they reduce their intensity, however I am not hearing a change.. I suspect I have forgot to set something. Thanks for your patience. |
Administrator
|
Hello.
Indeed, there is a (random) problem with fpc 3.0.x + LCL widget and Thread.Queue() method. Last uos-commit 0f15b08..d7b76fe uses Thread.Synchronize(). It seems that the synchro is safe now for LCL. Thanks to note it. Could you try your project with last uos release ? PS: IMHO it is better to use TForm.Activate in place of TForm.Create for all uos init stuff (uos_loadLib(), ...). Also do not forget to call uos_free() when application terminates. Fre;D |
Hi
Just downloaded latest uos as of today. App compiles and runs, howvever I am getting some audio crackles; mainly in the first 10 seconds. At first I though maybe it was the track, so loaded a much larger mp3 in. Tested compiled version using previous uos src files, no clicks/crackles. New src files I get clicks/crackles. This is using both just updated lazarus/fpc trunk and lazarus/fpc fixes. |
Administrator
|
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
|
Administrator
|
Re-hello.
Huh,... indeed there was a bug in the GetArrayFilter function... Could you try with the last uos commit d7b76fe..52ca515 ? Fre;D |
Free forum by Nabble | Edit this page |