<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Audio/XACT</title><link>http://forums.xna.com/forums/33.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: DirectSound from Memory in C#</title><link>http://forums.xna.com/forums/thread/205216.aspx</link><pubDate>Tue, 28 Jul 2009 12:56:51 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:205216</guid><dc:creator>darkin8</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/205216.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=33&amp;PostID=205216</wfw:commentRss><description>Hello. Did you find solution for your problem? I have the same noise in my sound.&lt;br /&gt;</description></item><item><title>DirectSound from Memory in C#</title><link>http://forums.xna.com/forums/thread/196026.aspx</link><pubDate>Fri, 03 Jul 2009 11:41:11 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:196026</guid><dc:creator>Starduster</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/196026.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=33&amp;PostID=196026</wfw:commentRss><description>I have written a C# program that takes raw PCM audio from a USB port and&lt;br /&gt;
plays it with DirectSound.  The audio originates from a microphone in a&lt;br /&gt;
wireless remote control and is sent to a USB receiver.   I read the audio&lt;br /&gt;
with the SerialPort in System.IO.Ports and put it in the SecondaryBuffer.&lt;br /&gt;
While the audio is understandable, it&amp;#39;s not good quality... sort of an echo&lt;br /&gt;
and clipped at the end of each packet.&lt;br /&gt;
&lt;br /&gt;
I&amp;#39;m obviously new at C# and DirectSound and here&amp;#39;s the code I&amp;#39;m using.  I&amp;#39;m&lt;br /&gt;
just taking the sound packets as they arrive and stuffing them in the&lt;br /&gt;
SecondaryBuffer.  I&amp;#39;m guessing there is a better way to do that.  Does&lt;br /&gt;
anyone have any suggestions as to how to clear up the audio?&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
&lt;br /&gt;
Steve&lt;br /&gt;
&lt;br /&gt;
        remoteFormat = new WaveFormat {&lt;br /&gt;
            AverageBytesPerSecond = 8000,&lt;br /&gt;
            BitsPerSample = 8,&lt;br /&gt;
            Channels = 1,&lt;br /&gt;
            SamplesPerSecond = 8000,&lt;br /&gt;
            BlockAlign = 1,&lt;br /&gt;
            FormatTag = WaveFormatTag.Pcm };&lt;br /&gt;
        sounddevice = new DS.Device();&lt;br /&gt;
        sounddevice.SetCooperativeLevel(this, CooperativeLevel.Priority);&lt;br /&gt;
&lt;br /&gt;
        buffDescription = new BufferDescription&lt;br /&gt;
        {&lt;br /&gt;
            BufferBytes = 60,&lt;br /&gt;
            Format = remoteFormat,&lt;br /&gt;
            DeferLocation = true,&lt;br /&gt;
            GlobalFocus = true&lt;br /&gt;
        };&lt;br /&gt;
        buffDescription.ControlEffects = false;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
                        //soundBuffer contains the raw audio&lt;br /&gt;
&lt;br /&gt;
                        audioBuffer = new SecondaryBuffer(buffDescription,&lt;br /&gt;
sounddevice);&lt;br /&gt;
                        audioBuffer.Write(0, soundBuffer,&lt;br /&gt;
LockFlag.EntireBuffer);&lt;br /&gt;
                        audioBuffer.SetCurrentPosition(0);&lt;br /&gt;
                        audioBuffer.Play(0, BufferPlayFlags.Default);&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;</description></item></channel></rss>