Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [C++ Win32] waveInGetDevCaps (argomenti)

    Salve,

    mi piacerebbe ottenere delle informazioni riguardanti i dispositivi di audio in input nel mio pc. Per ottenere questi dati devoi fare ricorso alla API di Win32 "Waveform" (winmm.lib). Per adesso l'unica funzione dell'api in questione che so usare è la seguente:

    waveInGetNumDevs
    codice:
    #include <windows.h>
    #pragma comment (lib, "winmm.lib")
    #include <mmsystem.h>
    #include <iostream>
    
    int main()
    {
    	UINT nDevices = waveInGetNumDevs();
    	std::cout << nDevices <<std::endl;
    	return 0;
    }
    che mi ritorna quanti dispositivi audio in input sono disponibili. Ora mi piacerebbe espandere il mio programma ed ottenere più info su ognuno di questi dispositivi, usando quindi la funzione waveInGetDevCaps che ha la seguente struttura:

    codice:
    MMRESULT waveInGetDevCaps(
        UINT uDeviceID,    // Identifier of the waveform-audio output device.
        LPWAVEINCAPS pwic, // Address of a WAVEINCAPS structure to be filled with information about the capabilities of the device.
        UINT cbwic         // Size, in bytes, of the WAVEINCAPS structure. 
    );
    quindi questa funzione ha bisogno in un parametro il passaggio ad una struttura del genere WAVEINCAPS

    codice:
    typedef struct {
       WORD wMid;                 // Manufacturer identifier for the device driver
       WORD wPid;                 // Product identifier for the waveform-audio input device.
       MMVERSION vDriverVersion;  // Version number of the device driver.
       CHAR szPname[MAXPNAMELEN]; // Product name in a null-terminated string. 
       DWORD dwFormats;           // Standard formats that are supported.
       WORD wChannels;            // Number specifying whether the device supports mono or stereo
       WORD wReserved1;           // Padding. (?)
    } WAVEINCAPS;
    ho provato quindi il seguente codice:

    codice:
    #include <windows.h>
    #pragma comment (lib, "winmm.lib")
    #include <mmsystem.h>
    #include <iostream>
    
    int main()
    {
    	UINT nDevices = waveInGetNumDevs();
    	WAVEINCAPS wcps;
    	waveInGetDevCaps(1,wcps,sizeof(wcps));
    	std::cout << nDevices <<std::endl;
    	return 0;
    }
    e questo è l'errore che ottengo:

    error C2664: 'waveInGetDevCapsA' : cannot convert parameter 2 from 'WAVEINCAPS' to 'LPWAVEINCAPSA'

    qual'è lo sbaglio??

    grazie
    Alla batteria dai retta ballA

  2. #2
    Utente di HTML.it L'avatar di XWolverineX
    Registrato dal
    Aug 2005
    residenza
    Prague
    Messaggi
    2,565
    Devi passargli l'indirizzo della struttura.
    "Se proprio devono piratare, almeno piratino il nostro." (Bill Gates)

    "Non è possibile che 2 istituzioni statali mi mettano esami nello stesso giorno." (XWolverineX)

    http://xvincentx.netsons.org/programBlog

  3. #3
    che svista

    ora funziona!

    codice:
    #include <windows.h>
    #pragma comment (lib, "winmm.lib")
    #include <mmsystem.h>
    #include <iostream>
    
    int main()
    {
    	UINT nDevices = waveInGetNumDevs();
    	WAVEINCAPS wcps;
    	for (int k=0; k<nDevices; k++)
    	{
    		waveInGetDevCaps(k,&wcps,sizeof(wcps));
    		char * devname = wcps.szPname;
    		std::cout << devname << std::endl;
    	}
    	return 0;
    }
    Alla batteria dai retta ballA

  4. #4
    Il codice che ho postati funziona ma il compilatore mi ritorna questo warning nella riga della FOR:

    warning C4018: '<' : signed/unsigned mismatch

    come mai??
    Alla batteria dai retta ballA

  5. #5
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,462
    codice:
    for (UINT k=0; k<nDevices; k++)
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  6. #6
    ok, ora funziona perfettamente senza warnings:

    codice:
    #include <windows.h>
    #pragma comment (lib, "winmm.lib")
    #include <mmsystem.h>
    #include <iostream>
    
    int main()
    {
    	UINT nDevices = waveInGetNumDevs();
    	WAVEINCAPS wcps;
    	for (UINT k=0; k<nDevices; k++)
    	{
    		waveInGetDevCaps(k,&wcps,sizeof(wcps));
    		std::cout << "uDevice" << k << std::endl;
    		std::cout << "wMid:" << wcps.wMid << std::endl;
    		std::cout << "wPid:" << wcps.wPid << std::endl;
    		std::cout << "vDriverVersion:" << wcps.vDriverVersion << std::endl;
    		std::cout << "szPname:" << wcps.szPname << std::endl;
    		std::cout << "dwFormats:" << wcps.dwFormats << std::endl;
    		std::cout << "wChannels:" << wcps.wChannels << std::endl;
    		std::cout << "wReserved1:" << wcps.wReserved1 << std::endl << std::endl;
    	}
    	return 0;
    }
    Alla batteria dai retta ballA

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.