Einzelnen Beitrag anzeigen

Kas Ob.

Registriert seit: 3. Sep 2023
263 Beiträge
 
#8

AW: Rechnerauslastung

  Alt 11. Jun 2024, 18:54
Hi, again !

I said in earlier post that will be my last about this, now my blood is boiling and i can't see this and see no one correcting you post #1, so i will comment here trying to correct few problems in your post, and again this will be my last about this subject, as you either don't understand me or not interested even in asking.

Sorry, i will put it as it, and that is every single line you wrote is wrong or have a misunderstanding and need an essay to explain.

Zitat:
Since I need the data very quickly, I call a routine in the main thread every 8 ms, which provides the data
Right, it should be handled and processed quickly, but how on earth are you calling a routine every 8ms !??, if that happen then you are tearing the sound card driver along with OS kernel a new ....
That is wrong.

Zitat:
and starts a second thread to process the data.
Why on earth you need a new thread for each 8ms buffer,
That is wrong.

Zitat:
The whole thing should run for around 10-15 minutes.
That's 112,500 threads that I start in 15 minutes.
WHAAAAATTT !
That is wrong on every imaginable level.

Zitat:
The routine that processes the data runs for around 200 ms.
How and what the hell this process that takes 8ms of samples sound data, and need 200ms, i am can't find any scenario for that be logical or correct, heck 8ms you might calculate its DFT with pen and paper and will not takes time much time, (sarcasm sorry) , but for real, the only thing i can make sense of, this 200ms process is drawing pixel on a GUI somewhere and utilizing TCriticalSection.
That is wrong.

Zitat:
This means that after 15 minutes 112,050 threads are still running.
That is wrong and should be considered as unthinkable.

Zitat:
I don't need to mention that this puts a lot of strain on the computer.
Strain is not the word, unsoldering every transistor and capacitor in your PC is more accurate description.

Zitat:
Now to my problem:
correction, problem -> problems

Zitat:
Does anyone have an idea?
Some might have, but you need to ask the right question.

Code:
function RecordingCallback( Handle : HRecord; buffer: Pointer; length: DWord; user: Pointer): boolean; stdcall ;
  var back: Boolean;
  var x1: integer;
  var x2:Cardinal;
  var ThreadHandle: THandle;
  var ThreadId: DWORD;
  var test7: PAnsiChar;
  var test8: integer;
  var test9: PAnsiChar;
begin
  back:=False;
  if Length > 0 then
  begin
    x2:=WaveStream. Write (buffer^,length);
    THreadNum:=Threadnum+1;
    back:=True;
    BASS_ChannelGetData(ChannelInput, @FFTData0, BASS_DATA_FFT4096);
    GetMem(test9, 8192);
    test7:=@FFTData0;
    for test8:=0 to 8191 do
    begin
      test9[test8]:=test7[test8];
    end ;
    address:=test9;
    ThreadHandle:=BeginThread( nil , 0, TFNThreadStartRoutine(@Calculate), nil , 0, ThreadId);
    if ThreadHandle <> 0 then CloseHandle(ThreadHandle);
  end ;
  Result:=back;
end ;
This callback doesn't make sense and wrong, let me break it for you:
The RecordingCallback receive length parameter and you are copying the data into some stream, then call BASS_ChannelGetData and handling the real length returned form it !!
Calling GetMem for 8kb, where did you get that length from ?!!! yes i see BASS_DATA_FFT4096 but that is not right at all, you should check what exactly are you getting.
I will assume you read http://bass.radio42.com/help/html/a1...fdf21bd463.htm and do understand returned bit(band) values.
As i remember NOAA and remember how it should processed, the process of the returned value from calculated DFT using FFT, is and as always get the logarithm of the value to get the amplitude.
"for test8:=0 to 8191 do" just use Move()

BeginThread is my favorite method to background threading, but that is wrong, very very wrong !
shouldn't be some data or pointer to data to pass to that thread !?? how it will know what to do.

Dear juelin, please don't be offended or takes this the wrong way, clearly you asked about this subject and you are trying to solve it, and i respect that so much, yes one should do it himself, but i suggested and pointed in different threads, and either you didn't understand my English (heck i am barely understand myself) or you are not interested in my solution as you didn't comment by a simple why or other questions.

For the last time and as i reminder i mentioned (i think in this forum) that VCP from LakeOfSoft way better than BASS when it comes to Delphi, it has DFT using FFT, and even support complex numbers and inverse, and on top of that all, it calibrated, i took time and made a video showing the bands with %100 Delphi code and it with full spectrum, also VCP comes with full multithread handling, so 0 work from you side on that, from the video i expected you go and just replace or just play with TunadspFFTControl, and see were and how it does the drawing and you will have you data (sorry i mean pixels)


Sorry again if i sound like retarded but i really tried to help and seeing all that wrong approach in one post is .... well trying to help last time.

One last thing on how to do it
that call back should only push the data in a buffer, this buffer will be FIFO (first in first out) and all you need is one thread (only one) check when there is data at specific count to perform the needed FFT width, and perform the DFT then process the pixels then push them into another FIFO buffer, and that is it !!..
you need a timer to copy the pixel to an image or simply redraw the image if you are putting the pixels directly on the image.

Sorry one more time, and if the admin or anyone see this post is offending or violate a policy then please delete it.
Kas
  Mit Zitat antworten Zitat