Waveform Questions

Started by djjoy, November 20, 2016, 08:28:21 AM

Previous topic - Next topic

djjoy

Hi again,

How can I make the reproduced wave part be displayed in one color,  and the one to be reproduced in another?
How can I paint in a different color a loop section?

Waiting for your reply,

Best Regards,

Jose Maria

Administrator

Hello,

this is not immediate with the Active Dj Studio component because its waveform rendering is not much advanced (for this purpose we have developed the Active Waveform Analyzer component http://www.multimediasoft.com/awavan) but you may draw the portion of waveform already played in a few  steps:
- set the Waveform.ColorLine property as you prefer
- draw the full waveform through the Waveform.BitmapViewDrawToHdc method setting 0 for the nStartPos parameter and -1 for the nEndPos parameter
- now set the Waveform.ColorLine property as you prefer for the portion alreasy played
- get the current playback position inside a nCurrPos variable using the SoundPositionGet method
- get the sound duration inside a nSoundDuration variable using the SoundDurationGet method
- calculate the drawing width for the played portion using the proportion:
   nPlayedWidth : nCurrPos = nTotalWidth : nSoundDuration
   so nPlayedWidth = (nCurrPos * nTotalWidth) / nSoundDuration
   where nTotalWidth is the value previously assigned to the nWidth parameter of the Waveform.BitmapViewDrawToHdc method
- draw the played portion of waveform through the Waveform.BitmapViewDrawToHdc method setting nPlayedWidth for the nWidth parameter, 0 for the nStartPos parameter and nCurrPos for the nEndPos parameter

For an eventual loop section you may mostly use the same procedure but, obviously, you would have to draw the loop portion starting from the loop start up to the loop end.

An easier approach would be using the aforementioned "Active Waveform Analyzer" control which can be used in conjuction with "Active DJ Studio" (or with any other multimedia library) and allows adding wave ranges drawn with different colors:
http://www.multimediasoft.com/awavan/help/how_to_graphic_items_to_wave.htm

Hope this helps

Kind Regards

Severino Delaurenti
MultiMedia Soft

djjoy

Hi again Severino.
I'm trying with ActiveWaveformAnaƱyzer, but I have many problems in Delphi to set/get parameters like the VC6 or VB6 examples.
Do you have examples in Delphi to understand and work allright?

Waiting for your reply,

Best regards,

Jose Maria

Administrator

Hello,

unfortunately we don't have samples in Delphi but, when dealing with Delphi, most of the problems when passing a data structure are due to a wrong porting of parameters size in bytes from C++ to Delphi: please, let me know the data structure you are having problems with so I may send you the correct size in bytes for related parameters.

Kind Regards

Severino Delaurenti
MultiMedia Soft

djjoy

I have problems to start using waveformanalyzer. I try to convert VC example to delphi, but i can't ( at the moment).
Now, i want to start with easy things:

I want to start with a simple wave visualization with native render:


  Amp3dj1.InitDJSystem(1, Handle, 0, 0, 0, 0);  //init amp3dj
  Amp3dj1.MediaFileDecoder.Initialize();
  ActiveWaveformAnalyzer1.InitWaveformAnalyzer(form1.Handle);  //init waveformanalyzer


  //open a new song
  Amp3dj1.LoadSound(0, OpenDialog1.FileName);

  //open song in waveformanalyzer to render
  nResult := ActiveWaveformAnalyzer1.AnalyzeSoundFromFile(OpenDialog1.FileName);
  if (nResult <> 0) then
  begin
       showmessage('Ups... Error'');
  end;

  //Play song
  AMp3dj1.PlaySound(0);
  timer1.enabled := true;



procedure TForm1.Timer1Timer(Sender: TObject);
var
fCurrPositionInMs: double;
begin

Amp3dj1.SoundPositionGet (0, &fCurrPositionInMs, 0);

      // pass the current playback position to the waveform control so it will be able to update the waveform scroller
      // and the position of the playback line in real-time
    //   ActiveWaveformAnalyzer2.PlaybackPositionSet(round(fCurrPositionInMs));
      ActiveWaveformAnalyzer1.PlaybackPositionSet(round(fCurrPositionInMs));
end;




djjoy

I get this error:


  nResult := ActiveWaveformAnalyzer1.AnalyzeSoundFromFile(OpenDialog1.FileName);   --> nresult value is ever -100. 

Administrator

Hello,

error -100 is usually raised when the trial version of the component is being used outside of the development machine and the internal protection schema blocks component's functionalities: may be that this is your case?
If it shouldn't, you may eventually attach the exe of your test project so we could test it in debug mode.

Kind Regards

Severino Delaurenti
MultiMedia Soft

djjoy

I solve the error issue installing againd the waveformdisplay components.
With the code above, I can't see the waveform on the component area.

I need to do something else to display a basic waveform?

Thanks.

Administrator

Hello.

Once the waveform analysis has been performed, you can immediately display the full waveform on the visible area of the analyzer through a call to the SetDisplayRange method by passing 0 and -1 respectively to the nBeginPosInMs and nEndPosInMs parameters.

Kind Regards

Severino Delaurenti
MultiMedia Soft