I am not trying to write a game.
Are there any API's that give the pitches in music such as:
c c# d d# e f etc.??
I have investigated PlaySound, IDirectMusicPerformance and
snaplaysound and they DON'T fill the bill.
I don't think MIDI is what I want either.
Looked in Petzolds book and found nothing.
Maybe there is a wav. file somewhere???
Thanks,
JPS
Are there any API's that give the pitches in music such as:
c c# d d# e f etc.??
I have investigated PlaySound, IDirectMusicPerformance and
snaplaysound and they DON'T fill the bill.
I don't think MIDI is what I want either.
Looked in Petzolds book and found nothing.
Maybe there is a wav. file somewhere???
Thanks,
JPS
By pitch, do you mean frequency?
One octave difference is a doubling of frequency. Since there are 12 notes in an octave (counting all the sharps and flats, ie, counting every key on a piano) leads to a formula of:
F(n) = Fo * 2 ^ (n/12) ; where Fo is some standard frequency,
; and n is the number of notes away from Fo (negative is OK)
Concert scale middle C is 440 Hz.
One octave difference is a doubling of frequency. Since there are 12 notes in an octave (counting all the sharps and flats, ie, counting every key on a piano) leads to a formula of:
F(n) = Fo * 2 ^ (n/12) ; where Fo is some standard frequency,
; and n is the number of notes away from Fo (negative is OK)
Concert scale middle C is 440 Hz.
Pitch " is " the frequency.
Don't know anything about making sound on a computer though.
What is the format of the data that you might send to a speaker through a port?
Does a double word represent a frequency and you just kepp sending that packet for your duration time?
:confused:
Don't know anything about making sound on a computer though.
What is the format of the data that you might send to a speaker through a port?
Does a double word represent a frequency and you just kepp sending that packet for your duration time?
:confused:
I'm not doubting that your math calc will work but that does not
help me keep in the windows API rut to conform with the rest of
windows. I think I should be using some API to handle the job.
In other words it doesn't seem right to write 90% of a program
conforming to windows specs and 10% in some low level code.
I am referring to the sound that hitting Middle C on the piano
would make.
Thanks,
JPS
help me keep in the windows API rut to conform with the rest of
windows. I think I should be using some API to handle the job.
In other words it doesn't seem right to write 90% of a program
conforming to windows specs and 10% in some low level code.
I am referring to the sound that hitting Middle C on the piano
would make.
Thanks,
JPS
I'm interested in this one too. Last time i played with sound was on an Apple II back in the mid 80's, all you had to do was beep the speaker, you achieved pitch by having the right length delay loop between beeps. And the C64 was easy too, you just had (IIRC) to nominate the pitch, then the attack/decay/sustain/ release for that note.
Nowdays, i have no freakin' idea how to generate music from scratch.
Nowdays, i have no freakin' idea how to generate music from scratch.
well, the way it used to be accomplished outside of Windows on an PC was by pulsing the speaker in and out after replacing one of the interrupts (don't remember which one, but it was the one which was called by the computer to update the clock).
back with DOS's GW-BASIC (and even /w QB), you could use the "SOUND" statement to generate a note from the speaker. SOUND frequency, length (in milliseconds). but QB (and maybe basica?) also had the "play" statement, greatly simplifying sound production. and then there was, of course, the beep statement, which played a fixed note for a fixed time interval. still exists in VB for Win (VB for DOS had it, i think), but sound and play have been removed. Perhaps there *is* no Windows API for it, except through MIDI.
back with DOS's GW-BASIC (and even /w QB), you could use the "SOUND" statement to generate a note from the speaker. SOUND frequency, length (in milliseconds). but QB (and maybe basica?) also had the "play" statement, greatly simplifying sound production. and then there was, of course, the beep statement, which played a fixed note for a fixed time interval. still exists in VB for Win (VB for DOS had it, i think), but sound and play have been removed. Perhaps there *is* no Windows API for it, except through MIDI.
Hi
Something I remember seeing you might look at..
http://www.stormpages.com/bojanjurca/CSamples.htm
Producing PC speaker sounds under Windows 9.x just as well as under Windows NT and 2000
Speaker.dll exports Sound function that produces a sound of a desired frequency and duration similar to Beep function under Windows NT but with one exception. The Sound function works under Windows 9.x as well.
Download Speaker.zip (6 KB) containing C source and compiled .dll file.
Kayaker
Something I remember seeing you might look at..
http://www.stormpages.com/bojanjurca/CSamples.htm
Producing PC speaker sounds under Windows 9.x just as well as under Windows NT and 2000
Speaker.dll exports Sound function that produces a sound of a desired frequency and duration similar to Beep function under Windows NT but with one exception. The Sound function works under Windows 9.x as well.
Download Speaker.zip (6 KB) containing C source and compiled .dll file.
Kayaker
You could just generate the sound (using sin or whatever you want) and then use the Windows API sound functions to play it.
You might want to search for:
FM (Frequency Modulation) Synthesis
WaveTable Synthesis
but I can't be sure since I don't study on this area. :)
FM (Frequency Modulation) Synthesis
WaveTable Synthesis
but I can't be sure since I don't study on this area. :)
By pitch, do you mean frequency?
One octave difference is a doubling of frequency. Since there are 12 notes in an octave (counting all the sharps and flats, ie, counting every key on a piano) leads to a formula of:
F(n) = Fo * 2 ^ (n/12) ; where Fo is some standard frequency,
; and n is the number of notes away from Fo (negative is OK)
Concert scale middle C is 440 Hz.
C is about 261.6 Hz (or 523.2 Hz the octave higher).
It appears that I my ONLY choice is to use interrupts and play with
the speaker. Since I am using Windows 98 2nd ed what will happen
if I take the program to windows XP? Most likely it will bomb.
Middle C is 261.63 hz and the A above it is 440hz. I found a list of all
the frequencies called equal-tempered at www.phy.mtu.edu/~suits/
notefreqs.html
Thanks for all the input,
JPS
the speaker. Since I am using Windows 98 2nd ed what will happen
if I take the program to windows XP? Most likely it will bomb.
Middle C is 261.63 hz and the A above it is 440hz. I found a list of all
the frequencies called equal-tempered at www.phy.mtu.edu/~suits/
notefreqs.html
Thanks for all the input,
JPS
You could use the api beep instead of interrupt! :)
BOOL Beep(
DWORD dwFreq, // sound frequency, in hertz
DWORD dwDuration // sound duration, in milliseconds
);:
It will work on winXP too if I recall correctly.
BOOL Beep(
DWORD dwFreq, // sound frequency, in hertz
DWORD dwDuration // sound duration, in milliseconds
);:
It will work on winXP too if I recall correctly.
I have included code that partially solves the problem of generating sound
in MASM32. I don't like what I hear and don't know if it's my crummy
speaker or something else.
Here is the code in BASIC that I used to create the MASM32 code:
10 count = 1193280! / 3000 ; 3000 is the desired frequency
20 lo.count = count mod 256 ; calculate low-order byte value
30 hi.count = count / 256 ; calculate high-order byte value
40 out &h43, &hb6 ; get timer ready
50 out &h42, lo.count ; load low-order byte
60 out &h42, hi.count ; load high-order byte
The bytes of this code have to be turned off to stop the sound.
The code I have included in MASM32 does not include the calculation
of the remainder of the frequency as I don't know how to do it.
Maybe that's why the sound is so bad.
What is the equivalent of "MOD" in MASM32??
in MASM32. I don't like what I hear and don't know if it's my crummy
speaker or something else.
Here is the code in BASIC that I used to create the MASM32 code:
10 count = 1193280! / 3000 ; 3000 is the desired frequency
20 lo.count = count mod 256 ; calculate low-order byte value
30 hi.count = count / 256 ; calculate high-order byte value
40 out &h43, &hb6 ; get timer ready
50 out &h42, lo.count ; load low-order byte
60 out &h42, hi.count ; load high-order byte
The bytes of this code have to be turned off to stop the sound.
The code I have included in MASM32 does not include the calculation
of the remainder of the frequency as I don't know how to do it.
Maybe that's why the sound is so bad.
What is the equivalent of "MOD" in MASM32??
My guess is you would need to make a wav engine, and feed this directly to the MAPI. You'd need to set up callbacks to generate the next note 'wav' in memory, and queue it befor the first finished playing. (Basically double buffering).
Somewhere a long time ago i did some wave stuff with this. Try here
:alright:
NaN
Somewhere a long time ago i did some wave stuff with this. Try here
:alright:
NaN
Havent looked at your source, but its not working correctly on Win98SE. The tone starts, and then turns into a very dull rumble (longer than the specified duration). I have a CreativeLive sound card that never gives me any fuss about anything.
:NaN:
:NaN: