Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DirectSound Secondary Buffer problem

DirectSound Secondary Buffer problem

Scheduled Pinned Locked Moved C#
data-structuresperformancehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrei Ungureanu
    wrote on last edited by
    #1

    Hi, I want to create an application that plays the sound recorded from the microphone. I succeeded in capturing the sound from the mic using CaptureBuffer....my problem is when using the data from this buffer to play it with SecondaryBuffer. I'm using a memory stream to get the data from the capture buffer to a stream. When I capture the data from the mic I use the following code. CaptureData is a byte array. memStream.Write(CaptureData, 0, CaptureData.Length); secBuffer = new SecondaryBuffer(memStream, appDevice); secBuffer.Play(0, BufferPlayFlags.Default); When i run my application it gives me System.ArgumentException was unhandled - Value does not fall within the expected range. Even if I use a different constructor, it always gives me this exception. I think it' because of the device object...This object is instantiated like this: appDevice = new Device(); appDevice.SetCooperativeLevel(this, CooperativeLevel.Priority); If any of you have a suggestion it will be most welcomed because I ran out of ideas. Thanks.

    Do your best to be the best

    L 1 Reply Last reply
    0
    • A Andrei Ungureanu

      Hi, I want to create an application that plays the sound recorded from the microphone. I succeeded in capturing the sound from the mic using CaptureBuffer....my problem is when using the data from this buffer to play it with SecondaryBuffer. I'm using a memory stream to get the data from the capture buffer to a stream. When I capture the data from the mic I use the following code. CaptureData is a byte array. memStream.Write(CaptureData, 0, CaptureData.Length); secBuffer = new SecondaryBuffer(memStream, appDevice); secBuffer.Play(0, BufferPlayFlags.Default); When i run my application it gives me System.ArgumentException was unhandled - Value does not fall within the expected range. Even if I use a different constructor, it always gives me this exception. I think it' because of the device object...This object is instantiated like this: appDevice = new Device(); appDevice.SetCooperativeLevel(this, CooperativeLevel.Priority); If any of you have a suggestion it will be most welcomed because I ran out of ideas. Thanks.

      Do your best to be the best

      L Offline
      L Offline
      Leslie Sanford
      wrote on last edited by
      #2

      Maybe you should use the constructor where you pass in a BufferDescription object to describe the format you're using. This is just a guess, but I think that since you got your stream for a capture buffer that it's not going to have the headers at the beginning that a stream loaded directly from a wave file would have. Thus you need to provide that info with the BufferDescription object. But don't quote me on that...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups