Announcement

Collapse
No announcement yet.

Help needed !!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help needed !!!

    Hi guys,

    i've a problem with a C++ header file !
    Is there someone who's can help me, to port this code to PB?
    My knowledge about C++ is not great enough to do this... :-(
    (The DLL i must use is called VOCTB3.DLL)

    Code:
    #ifndef __VOCTB_H
    #define __VOCTB_H
    
    #include <windows.h>
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #define VOCEXPORT __stdcall
    
    typedef enum tagConverterError
         { VOC_Ok = 0
         , VOC_Aborted = 1
         , VOC_CantOpenInfile = 2
         , VOC_CantOpenOutfile = 3
         , VOC_CantReadInfile = 4
         , VOC_CantWriteOutfile = 5
         , VOC_Unknown = 6
         , VOC_BadFormat = 7
         }ConverterError;
    
    typedef struct {char dummy[512]; } VOCAlaw2WavStruct;
    
    void           VOCEXPORT VOCAlaw2Wav          (VOCAlaw2WavStruct *p);               
    void           VOCEXPORT VOCAlaw2WavInit      (VOCAlaw2WavStruct *p, const char * src, const char *dest, short Loudness);
    void           VOCEXPORT VOCAlaw2WavAbort     (VOCAlaw2WavStruct *p);
    void           VOCEXPORT VOCAlaw2WavPolling   (VOCAlaw2WavStruct *p, short bytes);  
    short          VOCEXPORT VOCAlaw2WavGetPercent(VOCAlaw2WavStruct *p);
    BOOL           VOCEXPORT VOCAlaw2WavReady     (VOCAlaw2WavStruct *p);
    ConverterError VOCEXPORT VOCAlaw2WavGetError  (VOCAlaw2WavStruct *p);
    
    #ifdef __cplusplus
     }
    #endif
    
    #endif
    How must i call the "VOCWav2AlawInit" procedure ?

    Cheers an thank you !
    Klaus

    ------------------


    [This message has been edited by Klaus Mucke (edited January 02, 2003).]

  • #2
    Klaus,

    on the fly.

    Code:
    'needs PB7, for PB6 or older, remove the macros
    'and corrcet the declarations
    
    'a search in deja.com gave the following hint
    '
    'Thanks for your response, but the company told me to use cdecl, so the fault
    'must
    'be somewhere else.
    '
    'Best regards,
    '
    '   Steve Ludovicy
    'Read full thread here http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=VOCAlaw2WavInit&   btnG=Google+Search 
    
    
    Macro ConverterError = Dword
    Macro BOOL = Long
    
    %VOC_Ok = 0
    %VOC_Aborted = 1
    %VOC_CantOpenInfile = 2
    %VOC_CantOpenOutfile = 3
    %VOC_CantReadInfile = 4
    %VOC_CantWriteOutfile = 5
    %VOC_Unknown = 6
    %VOC_BadFormat = 7
    
    Type VOCAlaw2WavStruct
        dummy As Asciiz * 512 'or dummy(511) as Byte
                              'however, a buffer of 512 bytes
    End Type
    
    Declare Sub      VOCAlaw2Wav           CDecl Lib "Voctb32.dll" Alias "VOCAlaw2Wav"           (ByRef p As VOCAlaw2WavStruct)
    Declare Sub      VOCAlaw2WavInit       CDecl Lib "Voctb32.dll" Alias "VOCAlaw2WavInit"       (ByRef p As VOCAlaw2WavStruct, ByRef src As Asciiz, ByRef dest As Asciiz, ByVal Loudness As Integer)
    Declare Sub      VOCAlaw2WavAbort      CDecl Lib "Voctb32.dll" Alias "VOCAlaw2WavAbort"      (ByRef p As VOCAlaw2WavStruct)
    Declare Sub      VOCAlaw2WavPolling    CDecl Lib "Voctb32.dll" Alias "VOCAlaw2WavPolling"    (ByRef p As VOCAlaw2WavStruct, ByVal bytes As Integer)
    Declare Function VOCAlaw2WavGetPercent CDecl Lib "Voctb32.dll" Alias "VOCAlaw2WavGetPercent" (ByRef p As VOCAlaw2WavStruct) As Integer
    Declare Function VOCAlaw2WavReady      CDecl Lib "Voctb32.dll" Alias "VOCAlaw2WavReady"      (ByRef p As VOCAlaw2WavStruct) As BOOL
    Declare Function VOCAlaw2WavGetError   CDecl Lib "Voctb32.dll" Alias "VOCAlaw2WavGetError"   (ByRef p As VOCAlaw2WavStruct) As ConverterError

    These creepy code tags




    [This message has been edited by Torsten Rienow (edited January 02, 2003).]

    Comment


    • #3
      Code:
      #define VOCEXPORT __stdcall
      You sure you want CDECL in those DECLAREs?

      MCM


      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Thank you !

        Very nice, but how i call it ?
        Is that right ? Or What must i change ?
        especially "VOCWav2AlawStruct", how i use this parameter ?

        Code:
        VOCWav2AlawInit VOCWav2AlawStruct, WavFile, ALawFile, 0
        The compiler message me an error, whatever i change ...

        Klaus

        ------------------

        Comment


        • #5
          Michael,
          thx but i have seen the message at deja. I guess
          the DLL originator does not have changed their minds.

          Klaus,

          Ähm, wich compiler throws wich error message?

          '*************
          Dim WaveFile As (What?)
          Dim ALawFile as (What?)

          VOCWav2AlawInit VOCWav2AlawStruct, WavFile, ALawFile, 0
          '*************

          Best is you post the ORIGINAL C++ Example Code that
          calls the function. Maybe we find the missing fill in.

          Regards,

          Torsten




          ------------------

          Comment


          • #6
            Not just typo error?
            You declared VOCAlaw2WavInit and called VOCWav2AlawInit....

            ------------------
            Peter.
            mailto[email protected][email protected]</A>
            Regards,
            Peter

            Comment


            • #7
              Peter,

              you are qualified for the mega oops 2003.


              ------------------

              Comment


              • #8
                Sorry, i don't have more than the header file and i posted it
                completly. the rest of my code looks like:

                Code:
                SUB GoConvert(WavFile AS STRING, ALawFile AS STRING)
                 VOCWav2AlawInit VOCWav2AlawStruct, WavFile, ALawFile, 0
                 VOCWav2Alaw VOCWav2AlawStruct
                END SUB
                
                FUNCTION PBMAIN
                  goconvert "c:\test.wav"+CHR$(0), "c:\test.alw"+CHR$(0)
                END FUNCTION
                and i am found the following C-code:
                it looks like the "backward" function of my problem...

                Code:
                //////////////////////////////////////////////////////////////////////////////
                //  Lokale Defines:
                //
                #define START_FILENAME      "START.ALW"
                #define RECEIVE_FILENAME    "RECEIVED.ALW"
                #define CONVERT_FILENAME    "RECEIVED.WAV"
                
                BOOL __stdcall Play( HWND hDlg, unsigned message, WORD wParam, LONG lParam )
                {
                  static VOCAlaw2WavStruct    vs;
                
                  char        szTemp[128];
                
                
                  switch( message ) 
                  {
                    case  WM_INITDIALOG:
                    AppStatus = Playing;
                    strcpy(szMessage, "Spiele letzten Anruf ab...");
                    InvalidateRect(hwnd, NULL, TRUE);
                    //  Achtung, es gibt keine Fehlerbehandlung,
                    //  falls `SetTimer´ fehlschlägt.
                    SetTimer(hDlg, 0, 1000, NULL);
                    VOCAlaw2WavInit(&vs, RECEIVE_FILENAME, CONVERT_FILENAME, 0);
                    wsprintf(szTemp, "  0%% Done");
                    SetDlgItemText(hDlg, IDC_PERCENT_DONE, (LPSTR)szTemp);
                    return (TRUE);
                
                    case  WM_TIMER:
                    if( !VOCAlaw2WavReady(&vs) )
                    {
                      short   p;
                      
                      VOCAlaw2WavPolling(&vs, 8000);
                      p = VOCAlaw2WavGetPercent(&vs);
                      wsprintf(szTemp, "%3d%% Done", p);
                      SetDlgItemText(hDlg, IDC_PERCENT_DONE, (LPSTR)szTemp);
                    }
                    else
                    {
                      wsprintf(szTemp, "100%% Done");
                      SetDlgItemText(hDlg, IDC_PERCENT_DONE, (LPSTR)szTemp);
                      KillTimer(hDlg, 0);
                
                      sndPlaySound(CONVERT_FILENAME, SND_SYNC);
                    }
                    break;
                            
                    case  WM_COMMAND:
                    if( wParam == IDOK )
                    {
                      //  Der Timer in Dialog wird
                      //  normalerweise 2 x `gekillt´.
                      //  Das sollte aber keine Probleme bereiten.
                      KillTimer(hDlg, 0);
                      EndDialog(hDlg, TRUE);
                      AppStatus = Waiting;
                      strcpy(szMessage, "Warte auf Anruf...");
                      InvalidateRect(hwnd, NULL, TRUE);
                      return (TRUE);
                    }
                    break;
                  }
                  
                  return (FALSE);
                }
                Sorry, but C/C++ is not my thing.

                Klaus

                ------------------




                [This message has been edited by Klaus Mucke (edited January 02, 2003).]

                Comment


                • #9
                  Klaus,

                  please enclose code tags with [] instead of <>
                  click on the edit button of your last post to modify it.

                  please post the code lines that declares and fills the variables

                  RECEIVE_FILENAME

                  CONVERT_FILENAME

                  ------------------




                  [This message has been edited by Torsten Rienow (edited January 02, 2003).]

                  Comment


                  • #10
                    is ([email protected]) valid?

                    ------------------

                    Comment


                    • #11
                      [email protected] at this time, i must change it meanwhile ...
                      ... my personal anti-spam solution

                      Klaus

                      PS: I speak German too (better than English ;-))

                      ------------------

                      Comment


                      • #12
                        Michael is quite right. The deja.com remarks notwithstanding,
                        these functions are clearly defined using STDCALL, not CDECL.

                        Klaus, it appears VOCWav2AlawStruct is the name of the TYPE, not
                        the name of the variable. Pass the variable name, not the type name.

                        ------------------
                        Tom Hanlin
                        PowerBASIC Staff

                        Comment

                        Working...
                        X