|
Thanx a lot.
After making several changes i relised that values from streams in .wav files
are of type 'short' and not WORD (a.k.a. 'unsigned short').
In other words, values are between -32k to +32k and not 0 to 64k.
After reading them correctly, i turn them into positive by adding 32k,
mix them and turn the result into real by substructing 32k.
For mixing i use the way you just mention.
If i scale all gains,so that the sum of all gains is 1.00 ,
i don't have to worry about overflows.
I also heard about mixing using L2-node which is equal to:
sqrt(S1^2+S2^2+..+Sv^2)
But in this case you get overflow, and have to scale the
result with sqrt(2)=0.707
Also i don't know how to fit different gains in this formula (yet).
I will try the L2-node , and inform you about which one gives the
best result.
Memory leaks is the price we pay
|
|
|
|
|
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;
}
|
|
|
|
|
I already found out that its 16 signed but i
didn't know that i have to use log for reducing the volume.
Acually i never come to that point of handling volume and
never thought about it. I assume this have to do with mixing to.
For ex. (Sound1*0.33+Sound2*0.66) will give me Sound2 and half the
volume of Sound1 ?
What i am up to is a mixer where you could create filters using JScript.
Something like:
function OnGetStereoPaningAt(TimePosition)
{
// sound allways on the middle
return 0.5;
}
function OnGetStereoPaningAt(TimePosition)
{
// from left to right every 1 sec
return ( (TimePosition%44100)/44100 );
}
function OnGetWaveAt(TimePosition)
{
// return layer5 with 3sec echo
value w1=Document.layer5.Wave.GetValueAt(TimePosition);
value w2=Document.layer5.Wave.GetValueAt(TimePosition-44100*3);
return Mix(w1,w2,1,0.3) ;
}
Of course nothing of that is implemented right now.
|
|
|
|
|
I added the following line to my existing code which uses DirectSound,
stremaing to DirectSound buffer etc..
hres=m_pDsBuffer->QueryInterface(IID_IDirectSoundNotify,(LPVOID*)&lpDsNotify);
Now, I get the following error from linker:
error LNK2001: unresolved external symbol _IID_IDirectSoundNotify
P.S.
I think that the problem has something to do with comments in objbase.h (line 375)
any suggestions, ideas......
Thnx!
|
|
|
|
|
Hi Guys!
I got a project and I need making about 15 Buttons Bitmapped!
(CBitmapButton derived class)
The bitmapping done but one problem:
- I need the bitmaps to be transparented with any selected color, the color that is actually the background of the whole bitmap if you know what I mean? ie. the RGB(255,0,255) is the back of a bitmap.
- I tried the region (RGN) stuff but has a problem with loading the rest of the images! (3 state images), it just blits the 1st in the sequnce.
In advacnce, I Thank you!
|
|
|
|
|
I believe MaskBlt allows you to blt images using colour keys. It is not supported by Windows 95, so I'm not sure ( I wrote my own so I had W95 support ). I don't believe there is any way to get the colour keying you want unless you build it yourself.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I! Okay Mate!
Is there a way of having a sample? ( You can *hotmale* me? )
Thank you.
|
|
|
|
|
How would I "hotmale" you (sic) when you posted anonymously ?????
Anyhow, I'd rather post here, just in case anyone else is watching. Here is a function from a toolbar class I am about to submit here. It takes a bitmap ID, a position and a colour to mask. You should be able from this to see how to draw your buttons onto a new bitmap using a mask colour - to set a background colour just do a FillSolidRect across the DC first.
void CGSToolbar::OnChangeButton(int BitmapID, int Position,COLORREF Transp)
{
// This one takes a resource ID and uses a transparent colour key.
// I only needed the key here, so I only put it in once, but it would
// be very easy to port the transparency code to the function above, if desired.
CImageList* pImageList = GetToolBarCtrl().GetImageList();
ASSERT(pImageList);
CBitmap pButton,pMask;
pButton.LoadBitmap(BitmapID);
BITMAP bm; //windows bitmap structure
::GetObject(pButton,sizeof(BITMAP),&bm);
// Create a mask using magenta as transparent
CDC MaskDC,PicDC;
MaskDC.CreateCompatibleDC(NULL);
pMask.CreateBitmap(bm.bmWidth,bm.bmHeight,1,1,NULL);
MaskDC.SetBkColor(RGB(0,0,0));
MaskDC.SetTextColor(RGB(255,255,255));
MaskDC.SelectObject(pMask);
MaskDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,NULL,0,0,BLACKNESS);
PicDC.CreateCompatibleDC(NULL);
PicDC.SelectObject(pButton);
PicDC.SetBkColor(Transp);
MaskDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&PicDC,0,0,SRCINVERT);
PicDC.SetBkColor(RGB(0,0,0));
PicDC.SetTextColor(RGB(255,255,255));
PicDC.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MaskDC,0,0,SRCAND);
PicDC.DeleteDC();
MaskDC.DeleteDC();
pImageList->Replace(Position,&pButton,&pMask);
GetToolBarCtrl().SetImageList(pImageList);
Invalidate();
}
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Thank you Christian! You are very much appreciated, including your sense of humour!
|
|
|
|
|
Hi,
How can I set the text/background color for message boxes?
Thank you.
|
|
|
|
|
How can I display a tooltip without moving the mouse over a control?
Thank you.
|
|
|
|
|
i wrote this class called "CShowTooltipAutomaticallyWithoutMouseMovement" that does exactly....
ok ... no ... sorry ... i didnt ... and i'll tell you why free of charge
imagine having a dialog box with 6 edit controls all showing tootips at the same time with no way to remove them ... it gets uglier when you consider that some of the edit boxes might be obscured by the tooltips of other edit boxes
maybe a slight redesign of the interface you are trying to achieve would make things easier and clearer for both you and your users
and i'm sorry ... i'm not meaning to be rude or anything but a little thought on interface design does go a long way
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Hello, the codegurus around the world.
This requirement may be possible if we use Timer and SendMessage with
the dummy Mousemove and mouse position?
Unfortunetly, I don't have much time to try this
since I have my own project...
So, if anyone have a time, please write this cool class
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
masaaki i was kinda kidding
maybe its a cultural thing?
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
I search a class to create access database with tables,rows,all data types...
Thanks!
|
|
|
|
|
whilst i'm sure there is a class out there (as there is for anything nowadays) maybe you should just produce a sql script and execute it from within a setup program ... works for me
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Is anyone knows how to Send a Broadcast over LAN but in function Send(...) define the addresses to send the way that it sends a Broadcast to LAN but not sends it to himself.
Thanks.
|
|
|
|
|
Is anyone knows how to Send a Broadcast over LAN but in function Send(...) define the addresses to send the way that it sends a Broadcast to LAN but not sends it to himself.
Thanks.
|
|
|
|
|
Is anyone knows how can isend a broadcast on the LAN through UDP protocol without
sending it to my self also?
( I'm talking about CAsyncSocket level ).
Thanks.
|
|
|
|
|
surely you just ignore messages that you know originated from you so to speak
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
How many messages is in MFC ???
In Class wizard is 2 kinds :
Group 1: Before the message name is V character. Example : OnCommand
Group 2: Before the message name is W character. Example : WM_CREATE
Please explain to me about different kinds.
Thanks.
Hadi Rezaie
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
When i use of SetCapture() statment in program,
In fact my mouse pointer is capture, it mean i can't
any work with mouse, For example i can't click on
buttons or menu , ...
Please explain to me how can i use of SetCapture()
with good performance.
My source code :
void CTestDlg::OnOK()
{
HCURSOR h_Cursor;
h_Cursor = AfxGetApp()->LoadCursor(IDC_MYPOINTER);
SetCursor(h_Cursor);
SetCapture();
}
Thanks.
Hadi Rezaie
Hadi Rezaie
|
|
|
|
|
from your code snippet i assume you have a mdi or sdi app that shows a dialog box where you set the mouse capture ... if you look at msdn for SetCapture() you will see it says that all mouse messages are directed to the window with capture (your dialog) regardless of where the mouse is ... hence your other bits wont get to see mouse messages
also if your dialog is modal it will consume any other messages for your app until it is dismissed
hope this helps
mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them
|
|
|
|
|
Salam Hadi! Chetovri?
Why/What do you need SetCapture() for, and why in such a function OnOK() would you need to change the cursor?
Where do you exactly want your cursor to change? I'll help you, excpect an email from me soon.
|
|
|
|
|
I think you need to handle the WM_SETCURSOR message .
Good luck,
Dror
|
|
|
|
|