Page 1 of 1

frequency of actualy playing MCI-Audio

Posted: Wed Apr 06, 2005 3:00 pm
by Hroudtwolf
Hello PB-World,

How to get the momentary frequency from actualy bit of a playing MCI-Audio?

Re: frequency of actualy playing MCI-Audio

Posted: Wed Apr 06, 2005 4:12 pm
by traumatic
To determine the actual frequency components of a signal, you'd have to
FFT the raw buffer data. AFAIK you have no kind of direct buffer access via
MCI so to put it shortly: You can't!

Posted: Wed Apr 06, 2005 5:27 pm
by Hroudtwolf
Is somewhere a tutorial to the programming in PB with DirectX?

Posted: Wed Apr 06, 2005 5:50 pm
by traumatic
I don't know of any tutorials, however programming DirectX in PB is the
same as doing it in C. Just study the SDK and you're ready to go!

Here's a small example (DirectShow) that should give you the idea:

Code: Select all

;
;
;
; Minimal DirectShow Example for Hroudtwolf by (:t)raumatic! :)
;
;
;

#CLSCTX_INPROC_SERVER        = $1

#FILENAME = "YourAudioFile.EXT"

;
Procedure.l L(string.s)
  *out = AllocateMemory(Len(string)*2 * #SIZEOF_WORD)
  MultiByteToWideChar_(#CP_ACP, 0, string, -1, *out, Len(string))  
  ProcedureReturn *out  
EndProcedure


;
;
;
CoInitialize_(#NULL)

If CoCreateInstance_(?CLSID_FilterGraph, #NULL, #CLSCTX_INPROC_SERVER, ?IID_IGraphBuilder, @pGB.IGraphBuilder) = #S_OK
  If pGB\QueryInterface(?IID_IMediaControl, @pMC.IMediaControl) <> #S_OK
    Debug "QueryInterface() for IMediaControl failed"
  EndIf

  ;
  ; build the graph
  ;
  If pGB\RenderFile(L(#FILENAME), #NULL) = #S_OK
    ; run the graph to play the media file
    pMC\Run()
    MessageRequester("Minimal DirectShow Example", "playing...")
  Else
    ; file not found or unsupported
    MessageRequester("Minimal DirectShow Example", "oops... something went wrong")
  EndIf
EndIf

;
; cleanup
;
If pGB : pGB\Release() : pGB = #NULL : EndIf
If pMC : pMC\Release() : pMC = #NULL : EndIf

CoUninitialize_()

End


DataSection:
  CLSID_FilterGraph:
    Data.l $E436EBB3
    Data.w $524F, $11CE
    Data.b $9F, $53, $00, $20, $AF, $0B, $A7, $70
  
  IID_IGraphBuilder:
    Data.l $56A868A9
    Data.w $0AD4, $11CE
    Data.b $B0, $3A, $00, $20, $AF, $0B, $A7, $70

  IID_IMediaControl:
    Data.l $56A868B1
    Data.w $0AD4, $11CE
    Data.b $B0, $3A, $00, $20, $AF, $0B, $A7, $70
EndDataSection

Posted: Wed Apr 06, 2005 7:58 pm
by Hroudtwolf
Thanks. that is really nice.
I study your lines now.