Selecting Sound Input

This is a discussion on Selecting Sound Input within the C Programming forums, part of the General Programming Boards category; I'm trying to select Stereo Mix Record Line or Microphone Line. Making some modifications at this code, I can change ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    Fortaleza
    Posts
    6

    Selecting Sound Input

    I'm trying to select Stereo Mix Record Line or Microphone Line. Making some modifications at this code, I can change the volume, but I couldn't select the active line.

    What am I doing wrong? Thanks in advance.


    Source | Name | ID
    Source #1 = Mono Mix 1
    Source #1 = Stereo Mix 10001
    Source #1 = Entrada 20001
    Source #1 = CD player 30001
    Source #1 = Microfone 40001


    Code:
    #include <windows.h>
    #include <windowsx.h>
    #include <mmsystem.h>
    #include <commctrl.h>
    #include "stdio.h"
    
    int main(void) {
    
    unsigned long err, iNumDevs, i, n, numSrc;
    HMIXER mixerHandle;
    MIXERCAPS mixcaps;
    MIXERLINE mixerline;
    MMRESULT mmerr;
    
    MIXERCONTROLDETAILS_UNSIGNED mcdu = {0};
    MIXERCONTROLDETAILS mcd = {0};
    MIXERLINECONTROLS mixerLineControls = {0};
    MIXERCONTROL mixerControl = {0};
    MMRESULT result;
    
    err = mixerOpen(&mixerHandle, MIXER_OBJECTF_MIXER, 0, 0, 0);
    if (err)
    {
    printf("ERRO: %08X\n", err);
    }
    else
    {
    printf("OK!\n");
    
    mixerline.cbStruct = sizeof(MIXERLINE);
    mixerline.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_LINE;
    result = mixerGetLineInfo((HMIXEROBJ) mixerHandle, &mixerline, MIXER_GETLINEINFOF_COMPONENTTYPE);
    
    /*** GET ***/
    mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS);
    mixerLineControls.dwLineID = 0x20001; //ID of the input I want to select
    mixerLineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; //(mixerLineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX; to change input?)
    mixerLineControls.cControls = mixerline.cControls;
    mixerLineControls.pamxctrl = &mixerControl;
    mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL);
    if((result = mixerGetLineControls((HMIXEROBJ) mixerHandle, &mixerLineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE))) {
    printf("Error #%d calling mixerGetControlDetails()\n", result);
    } else {
    printf("It's value is %lu\n", mcdu.dwValue);
    }
    
    /*** SET ***/
    mcdu.dwValue = 40000; //New Volume     (mcdu.dwValue = TRUE; to change input?) 
    mcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    mcd.hwndOwner = 0;
    mcd.dwControlID = mixerControl.dwControlID;
    mcd.paDetails = &mcdu;
    mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
    mcd.cChannels = 1;
    if((result = mixerSetControlDetails((HMIXEROBJ) mixerHandle, &mcd, MIXER_SETCONTROLDETAILSF_VALUE))) {
    printf("Error #%d calling mixerSetControlDetails()\n", result);
    } else {
    printf("ok\n");
    }
    
    }
    
    system("PAUSE");
    return 0;
    }

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,618
    People can't read your code if you don't indent properly.

    Code:
    #include <windows.h>
    #include <windowsx.h>
    #include <mmsystem.h>
    #include <commctrl.h>
    #include "stdio.h"
    
    int main(void) {
    
    	unsigned long err, iNumDevs, i, n, numSrc;
    	HMIXER mixerHandle;
    	MIXERCAPS mixcaps;
    	MIXERLINE mixerline;
    	MMRESULT mmerr;
    
    	MIXERCONTROLDETAILS_UNSIGNED mcdu = {0};
    	MIXERCONTROLDETAILS mcd = {0};
    	MIXERLINECONTROLS mixerLineControls = {0};
    	MIXERCONTROL mixerControl = {0};
    	MMRESULT result;
    
    	err = mixerOpen(&mixerHandle, MIXER_OBJECTF_MIXER, 0, 0, 0);
    	if (err)
    	{
    		printf("ERRO: %08X\n", err);
    	}
    	else
    	{
    		printf("OK!\n");
    
    		mixerline.cbStruct = sizeof(MIXERLINE);
    		mixerline.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_LINE;
    		result = mixerGetLineInfo((HMIXEROBJ) mixerHandle, &mixerline, MIXER_GETLINEINFOF_COMPONENTTYPE);
    
    		/*** GET ***/
    		mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS);
    		mixerLineControls.dwLineID = 0x20001; //ID of the input I want to select
    		mixerLineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME; //(mixerLineControls.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX; to change input?)
    		mixerLineControls.cControls = mixerline.cControls;
    		mixerLineControls.pamxctrl = &mixerControl;
    		mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL);
    		if((result = mixerGetLineControls((HMIXEROBJ) mixerHandle, &mixerLineControls, MIXER_GETLINECONTROLSF_ONEBYTYPE))) {
    			printf("Error #%d calling mixerGetControlDetails()\n", result);
    		} else {
    			printf("It's value is %lu\n", mcdu.dwValue);
    		}
    
    		/*** SET ***/
    		mcdu.dwValue = 40000; //New Volume     (mcdu.dwValue = TRUE; to change input?) 
    		mcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    		mcd.hwndOwner = 0;
    		mcd.dwControlID = mixerControl.dwControlID;
    		mcd.paDetails = &mcdu;
    		mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
    		mcd.cChannels = 1;
    		if((result = mixerSetControlDetails((HMIXEROBJ) mixerHandle, &mcd, MIXER_SETCONTROLDETAILSF_VALUE))) {
    			printf("Error #%d calling mixerSetControlDetails()\n", result);
    		} else {
    			printf("ok\n");
    		}
    
    	}
    
    	system("PAUSE");
    	return 0;
    }
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 12:22 AM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  3. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  4. selecting input from a floppy
    By neilman88 in forum C++ Programming
    Replies: 1
    Last Post: 04-17-2003, 02:26 PM
  5. need help with some input
    By blindleaf in forum C Programming
    Replies: 2
    Last Post: 03-16-2003, 12:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21