TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Thomas
NA
7
0
DirectSound problem (Beginner)
Nov 27 2009 3:14 AM
Hi
I have spent a few evenings trying to get microphone-to-speaker-throughput using directsound (what is recorded from the line-in/mic-in should be played be played back instantly). I have set up the capture buffer and from testing the code it seems to work. I have also set up the playback buffer and can play wave files so next step is to transfer the capture buffer data to the playback buffer whenever the capture buffer is full.
I've done a fair bit of searching in google and I'm surprised not to find any available source code :( The microsoft documentation on the directsound API is not easy to read. It seems my next step is to add some notification functionality to the capture buffer such that when a certain amount of buffer has been filled a method can take care of the audio data transfer to the playback buffer.
http://msdn.microsoft.com/en-us/library/ee416303%28VS.85%29.aspx
But I can't understand how to add this notification functionality under C# (the example in the link above is for C++)
Can anyone please help out here?
My code looks like this:
sounddevice = new DS.Device();
sounddevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
BufferDescription description = new BufferDescription();
description.ControlEffects = false;
secBuffer = new SecondaryBuffer("shot.wav", description, sounddevice);
var format = new WaveFormat
{
SamplesPerSecond = 48000,
BitsPerSample = 16,
Channels = 2,
FormatTag = WaveFormatTag.Pcm
};
format.BlockAlign = (short)(format.Channels * (format.BitsPerSample / 8));
format.AverageBytesPerSecond = format.SamplesPerSecond * format.BlockAlign;
dsCapture = new Capture();
var cap = default(Capture);
CaptureDevicesCollection cdc = new CaptureDevicesCollection();
cap = new Capture(cdc[0].DriverGuid);
var capDesc = new CaptureBufferDescription
{
Format = format,
BufferBytes = 10*48000
};
cBuf = new CaptureBuffer(capDesc, cap);
Reply
Answers (
0
)
Differences between Constructors and Properties
Open source directx3d 10 examples