Configuration Steps
The following steps should be performed to set up playback of 4 independent mono streams. We are going to play in the following configuration:
Play 1 -> Line Out 1 Left Play 2 -> Line Out 1 Right Play 3 -> Line Out 2 Left Play 4 -> Line Out 2 Right
Find and set the channel mode controls on Play nodes as follows:
Play 1, Channel Mode = "stereo to left" -> Line Out 1 Left Play 2, Channel Mode = "stereo to right" -> Line Out 1 Right Play 3, Channel Mode = "stereo to left" -> Line Out 2 Left Play 4, Channel Mode = "stereo to right" -> Line Out 3 Right
The mixer also needs to be adjusted so that Play 1 -> Line Out 1 is set to full volume and Play 2 to Line Out 1 is also set to full volume.
These instructions remain the same whether the functionality is implemented with Microsoft Multimedia waveXXXX() and mixerXXX() calls, HPI or ASX calls.
00001 /* $Header: /Repository/apps/asx/examples/dual_mono_play/main.c,v 1.1 2007/01/29 18:33:31 as-age Exp $ */ 00002 00003 /* This examples sets up the playback channel mode controls to support dual mono playback. 00004 */ 00005 #include "stdio.h" 00006 #include "stdlib.h" 00007 #include "asx.h" 00008 #include "asxstring.h" 00009 00010 #define MAX_PLAYS 32 00011 00012 ASX_HANDLE hSystem=0; 00013 00014 int CheckError(ASX_HANDLE hObj, int nLine); 00015 void PrintControlName(ASX_HANDLE hControl); 00016 00017 int main(int argc, char* argv[]) 00018 { 00019 char *pszName; 00020 ASX_HANDLE hAdapter; 00021 ASX_HANDLE hMixer; 00022 ASX_HANDLE hChannelMode[MAX_PLAYS]; 00023 int nAdapterToUse=0; 00024 int i,nLen; 00025 00026 // create the system 00027 ASX_System_Create(ASX_SYSTEM_TYPE_HPI,&hSystem); 00028 CheckError(hSystem, __LINE__); 00029 00030 // get the adapter 00031 ASX_System_GetAdapter(hSystem,nAdapterToUse,&hAdapter); 00032 CheckError(hAdapter, __LINE__); 00033 00034 ASX_Adapter_GetName(hAdapter,0,0,&nLen); 00035 CheckError(hAdapter, __LINE__); 00036 pszName = (char *)malloc(nLen); 00037 ASX_Adapter_GetName(hAdapter,pszName,nLen,&nLen); 00038 CheckError(hAdapter, __LINE__); 00039 printf("Adapter [%d] is %s \n", nAdapterToUse,pszName); 00040 00041 // get the mixer handle 00042 ASX_Adapter_GetMixer( hAdapter, &hMixer ); 00043 CheckError(hAdapter, __LINE__); 00044 00045 // Grab a player's channel mode 00046 for(i=0; i<MAX_PLAYS; i++) 00047 { 00048 00049 // get channel mode object 00050 ASX_ERROR err = ASX_Mixer_GetControlByNodeTypeAndIndex( 00051 hMixer, 00052 asxNODE_PLAYER,i, 00053 0,0, 00054 asxCONTROL_CHANNEL_MODE, 00055 &hChannelMode[i]); 00056 if(err) // error will be returned when i > number of plays. 00057 break; 00058 00059 CheckError(hMixer, __LINE__); 00060 00061 // set the channel mode 00062 if((i&1)==0) 00063 { // even 00064 ASX_ChannelMode_Set( hChannelMode[i], asxCHANNELMODE_STEREOTOLEFT); 00065 CheckError(hChannelMode[i], __LINE__); 00066 } 00067 else 00068 { // odd 00069 ASX_ChannelMode_Set( hChannelMode[i], asxCHANNELMODE_STEREOTORIGHT); 00070 CheckError(hChannelMode[i], __LINE__); 00071 00072 } 00073 } 00074 00075 printf("Press ENTER to exit\n"); 00076 getchar(); 00077 ASX_System_Delete(hSystem); 00078 return 0; 00079 } 00080 00081 void PrintControlName(ASX_HANDLE hControl) 00082 { 00083 char *pszName; 00084 int nLen; 00085 enum asxCONTROL eControl; 00086 00087 ASX_Control_GetType(hControl, &eControl); 00088 ASXSTRING_EnumToString(eControl,0,0,&nLen); 00089 pszName=(char *)malloc(nLen); 00090 ASXSTRING_EnumToString(eControl,pszName,nLen,&nLen); 00091 printf("Control : %s\n",pszName); 00092 00093 free(pszName); 00094 } 00095 00096 int CheckError(ASX_HANDLE hObj, int nLine) 00097 { 00098 int nError; 00099 int asxSubSystemErrorCode=0; 00100 char *pszAsxErrorString; 00101 char *pszAsxSubSystemErrorString; 00102 int nLen1,nLen2; 00103 00104 ASX_Error_GetLast( hObj, &nError, &asxSubSystemErrorCode); 00105 if(!nError) 00106 return 0; 00107 ASX_Error_GetLastString( hObj, 0,0,&nLen1,0,0,&nLen2); 00108 pszAsxErrorString = (char *)malloc(nLen1); 00109 pszAsxSubSystemErrorString = (char *)malloc(nLen2); 00110 ASX_Error_GetLastString( hObj, pszAsxErrorString,nLen1,&nLen1,pszAsxSubSystemErrorString,nLen2,&nLen2); 00111 printf("Error: #%d, %s - Subsystem Error: #%ld, %s \n", 00112 nError, 00113 pszAsxErrorString, 00114 asxSubSystemErrorCode, 00115 pszAsxSubSystemErrorString ); 00116 printf("When called from source %s line %d\n",__FILE__,nLine); 00117 00118 printf("Press ENTER to exit\n"); 00119 getchar(); 00120 free(pszAsxErrorString); 00121 free(pszAsxSubSystemErrorString); 00122 ASX_System_Delete(hSystem); 00123 exit(1); 00124 return 1; 00125 } 00126
1.4.6-NO