Directsound - How To Play Wavs
Sep 6, 2011
i am new to directsound. I was wondering if someone could point to a resource that explains how to load wav files and play them using directsound. I found one webpage that explains how to load wavs and play them but you load them by clicking a button and searching a window for the file; what I need is programmatic loading. I can't use simpler methods to play the wavs because I need multiple sounds playing at once and very fast execution times. If it isn't too difficult, perhaps someone could post some code.
View 4 Replies
ADVERTISEMENT
Feb 14, 2009
I was wondering if anyone could point me to a really good tutorial on Directsound.I don't know if trying to digest an API is a good thing for a beginner but I really need something that has a beginner in mind.I especially liked some of the Microsoft video tutorials on VB.NET so perhaps they offer some on Directsound?The goal is to stream a WAV file, (not just "play it") and I want to LEARN the process.
View 3 Replies
Oct 15, 2010
I have the following code in my project: [code]The problem is, when I click the button, if the wav is not PCM I get the error: "Sound API only supports playing PCM wave files".This is fine but I want to play all wavs, mp3s and other types of files in my project. I read about using Flash but the only one example I found was for C#. My project is in vb.net. Is there no way to do this in vb.net? I absolutely do not want a player to appear in my application.
View 2 Replies
Dec 18, 2010
I'm currently trying to Capture through DirectSound, I've been trying toying around with WaveLib(Ported to VB) but this is very confusing. Anyway, I cant figure out how I am supposed to do this and would like some assistance. The end goal of this project is to: Record Microphone > Encode with Speex Codec > Send over UDP > Decode > Play on Speakers
View 3 Replies
Jun 18, 2011
I am trying to follow some tutorials on using DirectSound in VB.NET and I need a reference to Microsoft.DirectX.DirectSound in my project. I have downloaded and installed the Microsoft DirectX SDK (June 2010) but after a restart I have no additional .NET references available to add to my project. I must be doing something really dumb
View 2 Replies
Jul 13, 2011
where I'm going wrong with my circular DirectSound Capture buffer here? If I just capture sound into a big non-circular buffer it works fine, but with a 1 second (44100 bytes) buffer and a 100ms timer to poll the read position it goes haywire. No error messages, just long blocks of zeros with short bursts of valid data. calculation of the number of bytes to read and/or the read position.
Here is the code. gBuffer is defined elsewhere as a big byte array. In this example I am just trying to copy the captured sound data from the small temporary byte array (tempBuffer) into the big gBuffer byte array. Obviously this must be done so that every byte is read and copied into the byte array with no gaps or duplication of values. Timer1 is set to 100mS:
Dim McaptureBuffer As CaptureBuffer
Dim MiLastReadPos As Integer
Dim MiBufferOffset As Integer
[Code].....
View 2 Replies
Aug 6, 2011
I have used DirectSound to play a wave file in my application using the function CreateSoundBufferFromFile. It works perfectly.Now I want to play files from a resource dll file. I have created 1n2v32.dll file having nearly 100 small wave files named 1,2,3... I can play them using LoadLibraryEx, PlaySound & FreeLibrary.Now, I am trying to use CreateSoundBufferFromResource function from DirectSound api to play these files. I get Run-time error '432': File name or class name not found during Automation operation I used the following code to create the buffer.
Set LDSB = LDS.CreateSoundBufferFromResource(App.Path & "1n2v32.dll", "14", BufferDesc, gw)
View 6 Replies
Feb 8, 2012
I use the following code (with Imports Microsoft.DirectX.DirectSound and Microsoft.DirectX) to play sound using an 8 second static buffer:
Dim SD As Device = New Device
SD.SetCooperativeLevel(Me.Handle, CooperativeLevel.Priority)
Dim MS As New IO.MemoryStream(Gbuffer) ' Gbuffer is byte array with properly formatted WAV data
Dim waveFormat As New WaveFormat
waveFormat.SamplesPerSecond = 44100
[Code] .....
What I would like to do next is to change to a "circular" or "streaming" buffer so that I can write new data "on the fly". I've done a lot of Googling but can't quite see how to adapt my present code to use a circular buffer. I can get the current write and play positions using Msb.GetCurrentPosition(iPlayPos, iWritePos) but how do I actually insert new data into the buffer? I have tried "manually" writing new data into my Gbuffer byte array but that doesn't work - I guess once a sound has been played through once, the data is cached somewhere and the contents of Gbuffer are not used again.
View 7 Replies
May 8, 2010
I want to the song can auto start one by one when import the song to list box. But it doesn't work that I need to select one by one. Besides, the program can repeat all the song or individual song when checkbox enable.
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then
If playlistbox.SelectedIndex < playlistbox.Items.Count - 1 Then
[code].....
View 4 Replies
Nov 17, 2011
how to capture audio output with directsound? i'd want to be able to save it as .wav, .mp3, or .wma file format.
View 9 Replies
Apr 29, 2012
how can i create a buffer with BufferCaps.ControlEffects set to false in order to clone it? Here's the documentation
Public AudioData(7, 15) As SecondaryBuffer
Dim dev As New Device
Public Sub LoadAllData(ByVal ph As IntP
[code]....
View 2 Replies
Sep 16, 2009
So I was working in the forums and on the side bar of some thread I saw this link: [URL]...It turned out to be almost entirely about MIDI, but it made me think that I really need to share some code I wrote a few months ago and see if perhaps there is reason to create what the above thread really asked for.Here's a little background on the following code:
Back in April or so of this year I was doing some spring cleaning and came across the old Yahama PSR-6 synthesizer keyboard I had received one year for Christmas when I was around eight. I remember I used to like the Bagpipe voice because at the low notes it made a good fart sound. For a Toys-R-Us/Radio Shack model keyboard, running on six D-Cell batteries, produced in the early to mid eighties, that was an impressive achievement. LOL Anyway, I always did want to learn to play piano (or keyboard) so I decided to literally dust the thing off, put batteries in it, and fiddle around a bit. A couple YouTube videos later and I was convinced that I wanted to do this. While I was waiting for the thing to ship and arrive, I thought that it really shouldn't be that hard to take a DirectSound SecondaryBuffer object and inject it with sound data which whas calculated based on the harmonic values of musical notes, thereby creating your own synthesizer.
First, I really had little idea what I was doing when I first set about doing this other than the general structure of calculating byte data for notes and stuffing them into a SecondaryBuffer object while it played. I had used direct sound a number of times in a number of ways, but always playing sound data that came from a source (file, stream, etc.). This would be my first attempt at generating sound data for the buffer.
Second, I'm a "code-as-you-learn-learn-as-you-code" kinda guy, so that means that I developed the initial project as I went. I would research a specific portion of the project (and there was a LOT of research to do! lol) and then code it and move on to the next. Of course, this eventually leads to a mess of a project in most cases where the foundation is a bit complex to begin with. So the code I'm posting is the second version of the concept. But even at that, I'm only going to post the primary user control at this point and hold back on the code for the test application I created with it (I will provide a download to the compiled app however). After getting the user control cleaned up (if not ideally redesigned), the second app became a "develop-as-you-go" project for the test application - so it is a bit of a mess now too; but mostly just to look at code-wise - it actually runs pretty well.
Third, there are still a few design issues that could be improved upon in the user control, and a few choices which were made for ease of coding that could be changed for performance. But because of this, other than for a couple of routines, most of the code should actually be pretty straight forward to anyone who's comfortable in VB already.
Ok, on to the example: we are going to create a MusicKeyboard control. This control will draw itself like a pinao keyboard and will render keys for the specified number of full octaves. Clicking a key will play the associated note in the specified voice. Voices will be created using a simple digital oscillator and optional even-noise generator on top of a sine wave form.
To get started, you'll first need to have the DirectX SDK installed. The latest one is available here:[URL]..displaylang=en however the example was created using the version from March 09. There should be no impact from using the newer version.
Once you have the SDK installed, create a new Windows Application and add a new User Control named MusicKeyboard to the project. Note that you could create a Windows Class Library project, but I personally like to develop in an Application for ease of testing and later convert to a class library.You'll need to drag a BackgoundWorker component from the toolbox onto the usercontrol and name it "SynthWorker". Set the worker's WorkerSupportsCancellation property to True.
Now you'll need to add the DirectX reference to the project. You can rightclick the project in the solution explorer and select Add Reference or go to My Project and the References Tab. From the list of .Net references,add Microsoft.DirectX.DirectSound.That should be all we need to get started. In the following posts we'll create a bunch of code files and get the keyboard noise-worthy.Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
View 8 Replies
Sep 16, 2010
Im trying to open media player (full screen) and play a movie. When i create the file path like so: Dim MoviePathVTS As String = String.Concat("""" + tempMoviePath, " \VIDEO_TS\VTS_01_1.VOB" + """")
It wont play the file but if i do it like this: Dim video1 = """F:\Movies\DvD\Angels and Deamons\VIDEO_TS\VTS_01_1.VOB"""
It plays fine? the file paths are the same including the extra "" but it just refuses to play. I need the top one because i have many movies in a treeview.
Heres my code
Private Sub watchNow_Click(ByVal sender As Object, ByVal e As EventArgs)
'get the position of the selected node
Dim i = movieTreeView.SelectedNode.Index
[CODE]...
View 2 Replies
Feb 9, 2010
How can you make a play button play/stop toggle? Currently my button plays a file in WMP but when I click it again, it just restarts the file. I would like it to toggle on and off, play and stop, not play and pause.
View 8 Replies
Aug 28, 2009
I cant get this to work with an MP3 Audio file. It only works with .WAV, the reason im not using .WAV is cuse it takes a lot of space. So how can I play an MP3 File?
View 2 Replies
Jul 17, 2008
this is chandrashekar i am working on a project in that project to create impression to othersI want to play a background music
View 7 Replies
Apr 6, 2009
I have a .swf file that is about 29mb. I created a media player using a windows media player component.When i runt he application, it shows on the bottom that it is buffering? Is there a faster way to play media files?
View 8 Replies
Dec 27, 2010
I am having problems getting a .swf file to play in visual basic. Yes I have enabled .swf functionality. I am getting no errors. I created the .swf in adobe flash CS3, yes it will play if I open it in IE. But what I want to do is have it so it will play in the visual basic window. how to get this to work? it is called flash_engine.swf and it is my resources. my code is:
[Code]...
View 5 Replies
Nov 5, 2011
What is the best way to play music in the background of my program?
View 2 Replies
Jul 28, 2010
Is there any way to play MP3 directly from a memory stream (without any temp. files) using VB.NET or C#? or play from SQLCe database?
View 2 Replies
Jun 2, 2010
I have a program I'm trying to put together to allow my employees to submit shift reports. I'm doing this simply to make my life a little easier as this way, they will all be formatted the same. Instead of spending a large chunk of my afternoon thumbing through a bunch of differently formatted reports.
One feature that I need to figure out requires that one listbox can see what another is doing. Here, let me try to explain..
I have one list box that keeps track of EVERY action the employee does on a customers account. (cancel, upgrade, downgrade) and then a hidden listbox that JUST tracks "cancel" actions..one for "upgrade" actions and one for "downgrade" actions.
The reason behind that is that in the shift report, the all need to be listed separately. This way, I can just add each list to it's own array and list them where I need to.
The problem I've run into... If an employee handles an "upgrade" action at the beginning of the day..and then later on the upgrade is canceled, I can easily remove it from the main listbox that shows everything, however, I can't figure out how to find it in it's own listbox. The "Upgrade" box.
View 11 Replies
Aug 15, 2009
i have a voice that is sampeld and transmited to the computer via RS232, every time i am saving one byte with VB program. i need to play the sampeld voice at my computer, how can i do that at real time. can i play everytime only one byte? or i need to biled a string and then play it every few secound?
View 2 Replies
Jul 30, 2009
How can I play a MP3 sound using vb code in my application?
View 8 Replies
Jun 27, 2010
want to play a song when i click a button.... it s possible means, pls give an overview or give link to video tutorial
View 1 Replies
Nov 25, 2009
well i wanted to make a piano with visual basic 2008 and i searched around the internet to see how to play a sound but my search returned results relating only to visual basic 2005 & 6 so i am again forced to waste your time
View 3 Replies
Dec 19, 2009
how to play a Simple mp3 in the background, and if he presses a button itll stop/start the file, i do not want it to play in WMP, but just in Background of program.
View 1 Replies
Aug 29, 2009
I have put some wav audio on the resources. in my form, i have a label. i named the label as s1f1 and s1f2. now i want to play the audio according to the label click. if it is click then the audio play. i dont to put a line of code in every label. assuming that there is a lot of label, then it will be a waste of time. so how can i play the audio, by only write a several line code but for all of the labels.
View 7 Replies
Apr 3, 2012
How can i play a .wma file. it resembles a gunshot so it has to be played once.
View 4 Replies
May 25, 2010
I'm working on a game that plays MP3s at various points using the Windows Media Player component and it takes a long time to load and play MP3s. Would anyone know how to decrease the load time? I've considered multi-threading but I'm not sure how I would do that or if that's even the proper direction.
View 2 Replies
Mar 9, 2008
I need to create a VB.NET application which playes a song at a time from a predefined list of song.Basically, there is a list of Mp3 files which is completely hidden to the user and there are 5 buttons on the screen. Each button correspond to a different Mp3 and when the user presses one of them the song associated to that button starts to play. The time-elapse of each song is unknown and there is a timer which stops the song after
View 1 Replies