Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
GeneralRe: Set form's owner to a window outside the application? Pin
MogobuTheFool8-Jul-06 4:18
MogobuTheFool8-Jul-06 4:18 
Questionsetting the date format of the calendar in a datetimepicker Pin
microsoc10-Nov-05 19:28
microsoc10-Nov-05 19:28 
AnswerRe: setting the date format of the calendar in a datetimepicker Pin
krario10-Nov-05 20:07
krario10-Nov-05 20:07 
GeneralRe: setting the date format of the calendar in a datetimepicker Pin
microsoc10-Nov-05 20:20
microsoc10-Nov-05 20:20 
QuestionStatic and Dynaminc Assemblies ? Pin
webC#10-Nov-05 19:08
webC#10-Nov-05 19:08 
AnswerRe: Static and Dynaminc Assemblies ? Pin
J4amieC10-Nov-05 21:51
J4amieC10-Nov-05 21:51 
QuestionData Encryption in MySql Pin
Prashant Gadhave10-Nov-05 19:06
Prashant Gadhave10-Nov-05 19:06 
QuestionCapture Voice using DirectSound Pin
pakFari10-Nov-05 18:35
pakFari10-Nov-05 18:35 
Hi, I a trying to capture the voice using direct sound, but it is not working,here is my code can anyone help me, I will be very thankful to him.

private void CaptureThread()
{
MemoryStream inputStream = new MemoryStream(intervalSize);
while (button1.Text == "Stop")
{
bool val=bufferNotifyEvent.WaitOne();
int currentPos;
int readPos;
captureBuffer.GetCurrentPosition(out currentPos, out readPos);
inputStream.Position = 0;
captureBuffer.Read(0, inputStream, intervalSize, LockFlag.None);
outputBuffer.Write(0, inputStream, intervalSize , LockFlag.None);
outputBuffer.Play(0,BufferPlayFlags.Looping);
}
Stop();
}
the above code is the main thread that run to capture the voice, and some initializations are below

private void Form1_Load(object sender, System.EventArgs e)
{
WaveFormat waveFormat;
CaptureBufferDescription capBufDesc;
BufferPositionNotify[] notifyPositions;

bitsPerSample = 8; // 8 bits per sample
const int samplesPerSecond = 11025; // 11 KHz
const double interval = 1/45f; // Seconds
intervalSize = (int) (interval * samplesPerSecond * bitsPerSample / 8);
int samplesPerInterval = intervalSize * 8 / bitsPerSample;
int bufferSize = intervalSize * 2;

captureDevice = new Capture();
waveFormat = new WaveFormat();
waveFormat.BitsPerSample = bitsPerSample;
waveFormat.SamplesPerSecond = samplesPerSecond;
waveFormat.Channels = 1;
waveFormat.AverageBytesPerSecond = bitsPerSample * samplesPerSecond / 8;
waveFormat.BlockAlign = (short)(bitsPerSample / 8);
waveFormat.FormatTag = WaveFormatTag.Pcm;
capBufDesc = new CaptureBufferDescription();
capBufDesc.Format = waveFormat;
capBufDesc.BufferBytes = bufferSize;
captureBuffer = new CaptureBuffer(capBufDesc, captureDevice);
bufferNotify = new Notify(captureBuffer);
bufferNotifyEvent = new AutoResetEvent(false);
notifyPositions = new BufferPositionNotify[2];
notifyPositions[0] = new BufferPositionNotify();
notifyPositions[0].EventNotifyHandle = bufferNotifyEvent.Handle;
notifyPositions[0].Offset = intervalSize - (bitsPerSample / 8);
notifyPositions[1] = new BufferPositionNotify();
notifyPositions[1].EventNotifyHandle = bufferNotifyEvent.Handle;
notifyPositions[1].Offset = bufferSize - (bitsPerSample / 8);
bufferNotify.SetNotificationPositions(notifyPositions);

BufferDescription outputBufferDescription;
outputDevice = new Device();
outputDevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
outputBufferDescription = new BufferDescription(waveFormat);
outputBufferDescription.BufferBytes =(int)(intervalSize*1.5f-50);
outputBufferDescription.ControlVolume = true;
outputBufferDescription.GlobalFocus = true;
outputBuffer = new SecondaryBuffer(outputBufferDescription, outputDevice);
}
all the initialization in done in Load_page and the thread will run the user will press the button, but no voice is captured, plz guide me, I will be thankful to u,


Questionsql statement problem Pin
ppp00110-Nov-05 18:32
ppp00110-Nov-05 18:32 
AnswerRe: sql statement problem Pin
jonny511-Nov-05 0:31
jonny511-Nov-05 0:31 
Questionwhat is the complete code for downloading a file using FTP through ASP.NET/C# Pin
v.k.s10-Nov-05 17:26
v.k.s10-Nov-05 17:26 
AnswerRe: what is the complete code for downloading a file using FTP through ASP.NET/C# Pin
Ravi Bhavnani11-Nov-05 5:51
professionalRavi Bhavnani11-Nov-05 5:51 
QuestionC# App Error Pin
nosferatu200010-Nov-05 17:10
nosferatu200010-Nov-05 17:10 
AnswerRe: C# App Error Pin
J4amieC10-Nov-05 21:48
J4amieC10-Nov-05 21:48 
Questiondisplay from system tray issues Pin
lushgrass10-Nov-05 16:52
lushgrass10-Nov-05 16:52 
QuestionC# and mysql Pin
vandread110-Nov-05 13:18
vandread110-Nov-05 13:18 
AnswerRe: C# and mysql Pin
Christian Graus10-Nov-05 13:33
protectorChristian Graus10-Nov-05 13:33 
GeneralRe: C# and mysql Pin
vandread110-Nov-05 13:39
vandread110-Nov-05 13:39 
GeneralRe: C# and mysql Pin
Christian Graus10-Nov-05 13:53
protectorChristian Graus10-Nov-05 13:53 
QuestionSocket question Pin
Tom Wright10-Nov-05 12:40
Tom Wright10-Nov-05 12:40 
AnswerRe: Socket question Pin
User 58385210-Nov-05 16:40
User 58385210-Nov-05 16:40 
GeneralRe: Socket question Pin
Tom Wright11-Nov-05 4:55
Tom Wright11-Nov-05 4:55 
GeneralRe: Socket question Pin
Tom Wright12-Nov-05 3:20
Tom Wright12-Nov-05 3:20 
QuestionCaching multiple ArrayLists Pin
Rlearning10-Nov-05 12:40
Rlearning10-Nov-05 12:40 
AnswerRe: Caching multiple ArrayLists Pin
Christian Graus10-Nov-05 13:06
protectorChristian Graus10-Nov-05 13:06 

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.