Click here to Skip to main content
16,012,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Highlight CWnd? Pin
l a u r e n19-Feb-01 10:57
l a u r e n19-Feb-01 10:57 
GeneralRe: Highlight CWnd? Pin
ov19-Feb-01 22:04
ov19-Feb-01 22:04 
GeneralRe: Highlight CWnd? Pin
20-Feb-01 2:10
suss20-Feb-01 2:10 
GeneralNon-overlapped serial comms Pin
Joe Moldovan19-Feb-01 5:47
Joe Moldovan19-Feb-01 5:47 
GeneralSoftware Mix of Sound Pin
Datacrime19-Feb-01 2:34
Datacrime19-Feb-01 2:34 
GeneralRe: Software Mix of Sound Pin
.::RockNix::.19-Feb-01 21:07
.::RockNix::.19-Feb-01 21:07 
GeneralRe: Software Mix of Sound Pin
Datacrime19-Feb-01 22:27
Datacrime19-Feb-01 22:27 
GeneralRe: Software Mix of Sound Pin
Joe Moldovan19-Feb-01 23:55
Joe Moldovan19-Feb-01 23:55 
I assume you are mixing 16 bit PCM files streams. If that's the case then you have two problems:

1. The sound is stored as 16 bit SIGNED walues not WORD (unsigned int) values. The amplitude is between –32768 and 32767. You reduce the amplitude by going towards 0.

2. The amplitude is not linear. If you halve the amplitude the sound will not be half as loud. It follows a logarithmic law and something to do with 20*Log(A) where A is the amplitude. (I don't know the theory real well...life is too short.) The library should be full of books which will help you.

Hope you get it working. I love playing around with audio but don't have the time.

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

PS: I made time! The following is a very primitive C mixer I threw together. It works but probably has bugs. I used CoolEdit to capture raw PCM files. If you use WAV files then just strip the headers first to get to the PCM data. But you probably already know that. You can also use the API to get the data a lot neater.

#include "stdafx.h"
#include <stdio.h>

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
FILE *f1;
FILE *f2;
FILE *f3;

size_t result1;
size_t result2;

short buffer1[ 0xFFFF ];
short buffer2[ 0xFFFF ];
short buffer3[ 0xFFFF ];

int i;

f1 = fopen( "sound1.pcm", "rb" );
f2 = fopen( "sound2.pcm", "rb" );
f3 = fopen( "sound3.pcm", "wb" );

do
{
result1 = fread( buffer1, sizeof( short ), 0xFFFF, f1 );

result2 = fread( buffer2, sizeof( short ), 0xFFFF, f2 );

for ( i = 0; i < 0xFFFF; i++ )
{
buffer3[ i ] = buffer1[ i ] / 2 + buffer2[ i ] / 2;
}

fwrite( buffer3, sizeof( short ), 0xFFFF, f3 );

} while ( !feof( f1 ));

fclose( f1 );
fclose( f2 );
fclose( f3 );

return 0;
}
GeneralRe: Software Mix of Sound Pin
Datacrime20-Feb-01 4:01
Datacrime20-Feb-01 4:01 
GeneralIDirectSound and linker error LNK2001 Pin
19-Feb-01 0:51
suss19-Feb-01 0:51 
GeneralBitmapped Buttons with A Color Transparency. Pin
18-Feb-01 23:40
suss18-Feb-01 23:40 
GeneralRe: Bitmapped Buttons with A Color Transparency. Pin
Christian Graus19-Feb-01 0:05
protectorChristian Graus19-Feb-01 0:05 
GeneralRe: Bitmapped Buttons with A Color Transparency. Pin
19-Feb-01 0:33
suss19-Feb-01 0:33 
GeneralRe: Bitmapped Buttons with A Color Transparency. Pin
Christian Graus19-Feb-01 10:56
protectorChristian Graus19-Feb-01 10:56 
GeneralRe: Bitmapped Buttons with A Color Transparency. Pin
19-Feb-01 21:37
suss19-Feb-01 21:37 
QuestionColoured message boxes? Pin
Sachin18-Feb-01 23:36
Sachin18-Feb-01 23:36 
QuestionHow can I show a tooltip automatically without mouse movement Pin
Sachin18-Feb-01 23:31
Sachin18-Feb-01 23:31 
AnswerRe: How can I show a tooltip automatically without mouse movement Pin
l a u r e n19-Feb-01 6:28
l a u r e n19-Feb-01 6:28 
GeneralRe: Maybe, possible ? Pin
Masaaki Onishi19-Feb-01 9:52
Masaaki Onishi19-Feb-01 9:52 
GeneralRe: Maybe, possible ? Pin
l a u r e n19-Feb-01 11:08
l a u r e n19-Feb-01 11:08 
GeneralCreate a MDB Database Pin
18-Feb-01 22:31
suss18-Feb-01 22:31 
GeneralRe: Create a MDB Database Pin
l a u r e n19-Feb-01 6:10
l a u r e n19-Feb-01 6:10 
GeneralUDP OnSend Broadcast Pin
18-Feb-01 20:50
suss18-Feb-01 20:50 
GeneralUDP OnSend Broadcast Pin
Gleb18-Feb-01 20:50
Gleb18-Feb-01 20:50 
GeneralUDP Broadcast Pin
Gleb18-Feb-01 19:02
Gleb18-Feb-01 19:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.