Advertisement

Beep, beep, beep, beeeeeeeep!!!

Started by May 23, 2001 09:12 AM
7 comments, last by MrSandman666 23 years, 8 months ago
Hello, guys, I''m back again! I got another little stupid question for you. This isn''t exactly game related but it''s pretty cool and I figured that all you game programmers might know something about this. I simply need to find a way to make the computer play a beeping sound. I use it to program the computer to play music with improvising and everything. It''s a little bit like an artificial digital musician which can improvise its own solos. Right now I use the internal speaker and the Beep() function (in C++). The problem with that is: it only works on Windows NT based systems and it sounds crappy. Is there a way to just put out a certain frequency via the soundcard for a certain time? Something like Beep(int frequency, int duration)? And is there a way to record that in a file? Just for demos and such. But that''s not as importand as generating the tone in the first place. ANY help would be greatly appreciated. As always, yours sincerely MrSandman666 ----------------------------- "Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
I guess you could use DirectSound and just generate the wave data yourself and stream it into a buffer.

Good luck anyways.

Waassaap!!
Waassaap!!
Advertisement
maybe you could write a little "driver" for adLib soundcards..look for a tutorial on the net, i think when i looked into it , it wasnt so hard to generate a tone...

--spencer
--Spencer"All in accordance with the prophecy..."
Hmmmm, i really don''t want to use DirectSound, because I want the program to run on Windows NT Machines, too, for which I would have to use DirectX 3 or so and that version isn''t exactly supported by Microsoft any more. I searched a little and couldn''t find any tutorials on that. Besides, I bet it takes about 100 Lines of code to just produce a single tone.

I also tried to find adLib tutorials. The only ones I found are on this site and they''re all greek to me. I didn''t understand a word.

Yeah, well, are there any alternatives?

-----------------------------
"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
You could use midi instead. midiOutOpen, etc... Not too hard to use. You could even use a sequencer program to generate a standard midi file, and then use the windows mci stuff to play it. Sounds like if you are working on improv stuff you want to use midi instead of waveform audio

DSutherland
Well, I dug a little into that midi stuff and it sounds really good, except that it doesn't make any sound. I even found a tutorial but when I run my program it just doesn't produce any sounds. The functions all run perfectly and without a single error. I find 2 midi devices, open one of them play a tone, wait for two seconds, stop the tone and close the device again. But I can't hear anything! Yes, the speakers are on, and on full volume. I also checked the windows sound controlls.
The two devices I found might be a problem. The one doesn't have any voices or tones listed in the device caps and the other one is the Microsoft Wavetable Synthesizer. They both showed up when I went through the midi devices.

this is the code of my program:
      #include <iostream.h>#include <windows.h>#include <mmsystem.h>void main (){	HMIDIOUT Output;	MIDIOUTCAPS moc;	unsigned int timer;	int x;	x = midiOutGetNumDevs();	cout << x << " midi output devices found..." << endl;	for(int i = 0; i < x; i++)		if (!midiOutGetDevCaps(i, &moc, sizeof(MIDIOUTCAPS)))		{			cout << "Device ID #" << i << ": " << moc.szPname << " " << moc.vDriverVersion << endl;			cout << "\tVoices:" << moc.wVoices << endl;			cout << "\tNotes:" << moc.wNotes << endl << endl;		}	midiOutOpen(&Output, 1, 0, 0, CALLBACK_NULL);		Test = midiOutShortMsg(Output, 0x00FF3C91);	timer = timeGetTime();	while(timeGetTime() < timer + Interval);	midiOutShortMsg(Output, 0x00003C91);	midiOutClose(Output);	}      


This should work, shouldn't it? I took out all the error checking. In the actual program I check for pretty much every error possibly imaginable. I select device number 1 and not 0 in this case because device 0 has 0 voices and 0 notes. Device 1, the one I use is the Microsoft Wavetable Synthesizer.

Can anybody see what's wrong here? Oh yeah, if it helps anything, I tested it on Windows 2000 and NT 4.0 with the same results.

Thanks in advance...

Edited by - MrSandman666 on May 25, 2001 11:30:17 AM
-----------------------------"Mr Sandman bring me a dream"
Advertisement
Ok, I tested it on another NT 4.0 box now, and it detected the following systems:
Name: SB PCI128 MIDI Synth 256
Voices: 31
Notes: 31

Name: SB PCI128 MIDI Out 256
Voices: 0
Notes: 0

I chose the Synth because the MIDI Out doesn't have any voices or tones. Still, no sounds. I also tried the other one, the MIDI Out. No sound either.
This starts to get annoying...


Edited by - MrSandman666 on May 25, 2001 11:21:04 AM
-----------------------------"Mr Sandman bring me a dream"
Heh what is that midi command you are sending?

Try this:

midiOutShortMsg(Output, 0x00403C90); // C
midiOutShortMsg(Output, 0x00404090); // E
midiOutShortMsg(Output, 0x00404390); // G

It isn't playing a note because I think you got the message wrong.

Here is a site that may help you:
Low Level MIDI API under Windows

Best regards,




Dire Wolf
www.digitalfiends.com

Edited by - Dire.Wolf on May 25, 2001 6:56:11 PM
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
No, that wasn''t it. I based my whole program on that tutorial. We''re using the same site. I also started out with the same messages as they mention in the tutorial but it didn''t work. It''s almost like the computers are out to get me. They WANT to drive me crazy!

-----------------------------
"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"

This topic is closed to new replies.

Advertisement