Re: Direct Soundcard Control
To produce your own waveforms you will need to use mathematical functions to create the byte stream and you can then use the Playsound API to play it..
it you need more help with this, just holer..
Gremmy.....
Re: Direct Soundcard Control
Gremmy,
Thanks for the reply, but..., the examples just show how to play a wav file. I want to be able to setup the attack, sustain, decay, and release of A single wave form and control the output. Kindof like the old Commodre computers allowed you to do. If I wanted to send out a triangle wave, a square wave, a sawtooth wave, stepped sine, pure sine, etc... and be able to vary the frequency, how do I control the soundcard directly. For example, during the early days of PCs a sound card would have a buss address of around H300 then you could control different registers by POKEing values into different addresses, hense controlling the soundcards output.
I am trying to generate IRIG-B though software and the soundcard output (which can be done) instead of by my hardware.
Hope this is understandable!!!
thanks,
Keith
Re: Direct Soundcard Control
Oooo i loved the C64 sound....
I'll see if i can put together a little project for you..
Gremmy...
Re: Direct Soundcard Control
Thanks, I understand the function calls, but I want to do more than play, stop, ff, rew, etc.....
Keith
Re: Direct Soundcard Control
Gremmy, You know, If I could figure out how to send just 1 cycle of a sine wave at 1KHz or (1ms) at different amplification levels, then the rest should be easy. What do you think?
Keith
Re: Direct Soundcard Control
You just need the mathematicle function to produce this wave at, lets say 11khz, in a array..
you then can alter the array values accordingly, then pass the array to playsnd...
at the mo this looks like the best way to turn...
gremmy...
Re: Direct Soundcard Control
OK, I can create the array with the correct values, but how do I pass it to playsound, when it is looking for a filename to play? Sorry for the illiteritcy (sp?) Keith
1 Attachment(s)
Re: Direct Soundcard Control
Playsound does accept memory locations...
attached is a old shelved project of mine, with alot of sample code to help you...
have fun with it...
Almost time for me to hit the sack, but over the weekend i will look into making a project closer to what your trying to do..
Gremmy...
2 Attachment(s)
Re: Direct Soundcard Control
Gremmy,
I found some code for what I think is DirectSound. The Sine...zip file is the original, and I have similified it to test4gremmy.zip
(Sine...zip is VB6 & test4gremmy.zip is VB5) (I don't have VB6)
Problem, I can get 1 pulse out (1 single sinewave at 1khz), but then I don't get another pulse out until 20ms later. Even with playing with the timer to 1ms. Is there a min time for Timer? and is there a min. time for the Directsound calls?
Also, where can I get a list of all the functions and description of the Directsound function calls?
Thanks,
Keith
Re: Direct Soundcard Control
Hey this is a good find....
Okay i hear the problem that you have with this..
I will dig around the code a little and see what i can come up with...
Gremmy....
Re: Direct Soundcard Control
Okay i got it...
very simple...
in the Form Activate sub change the following line...
Code:
DSB(0).Play DSBPLAY_DEFAULT
TO
Code:
DSB(0).Play DSBPLAY_LOOPING
and comment out the same line in the Timer event....
This will give you the constant tone, your looking for...
Cheers ...
Gremmy...
Re: Direct Soundcard Control
Timers are effective only down to 10-20ms. That would be the additional lag that you get.
Re: Direct Soundcard Control
Hi Gremmy, Correct, I can get a nice constant tone out, but.... I need to have control of the amplitude (volume) to an accuracy of each cycle. Even putting the following:
dsb(0).play dsbplay_default
dsb(0).play dsbplay_default
back to back, I still get a lag of 20ms before the 2nd command is executed, (sometimes it isn't executed at all) The function call must take all the computer process time until it is finished with whatever it has to do, which I don't know what that is.
There is software out there that can produce IRIG-B signal out the speaker port, but they are reading the computer time and then producing an output. This is kindof what I want, but I want to count down to an event, and output the time in an IRIG-B format.
I just don't know if they did it in C or VB. I did read that with C you have more control over hardware items, but I don't know if that is exactly true.
and, they are not so eager to let me in on their secret.
I will keep plugging away, and see what I come up with.
Thanks,
Keith
1 Attachment(s)
Re: Direct Soundcard Control
I whould say leave the tone to play constant, and in your timer event use the setvolume to play with the amplitude..
I've moded your project a little to show how this can be done ...
Have fun
Gremmy...