• Advertisement

Archived

This topic is now archived and is closed to further replies.

home made music for game

This topic is 5718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I play guitar and I would like to know witch typr of sound format I should use. I''m making up a lot of cool sounds for one of my friends RPG and my Galaxian clone. My problem is I want a file that won''t take up tons of space, but will still sound good. I was thinking something like 8 bit stereo .WAV. I notice that wav files take up alot of space witch I don''t want. The key here that I want is small size and quality. Because if I put hours into a song and it turns out sounding like a cat getting his nuts beaten with a rubber mallet, there were first stapled to plywood. Then it dosn''t realy do me much good, does it.

Share this post


Link to post
Share on other sites
Advertisement
Ogg Vorbis; Small, free, open-source, good quality and non of the nasty mp3-licensing issues. Alternately, under Windows .WMA offers (subjectively) better quality and plenty of documentation in the MSDN.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Cool, just what I was looking for.
Now I can have my music on my game.
This Galaxian clone is coming along pretty good
Alot better then I though it was going to be.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Cool, just what I was looking for.
Now I can have my music on my game.
This Galaxian clone is coming along pretty good
Alot better then I though it was going to be.

Share this post


Link to post
Share on other sites
Of course you can always downsample the sound to something like 22KHz 8-bit Mono (you don''t really need stereo for SFX)...but you will loose some of the *really* high freqs. But if you have lots of action and some music in the background anyway, you definitely won''t notice it

Alternatively, just zip or RAR the files and just decompress them while the game loads or something...I dunno. I''m no expert on game coding at all...

Share this post


Link to post
Share on other sites
But a compressive audio format such as mp3, WMA or ogg will have better quality, and a much smaller file size then even 8-bit 22Khz files. Only psychoacoustically redundant information ( inaudible frequencies ) are removed, and whilst this will be apparent to audio gimps, most people won''t notice. The only advantage with a WAV is more optimal playback, although if this a problem the mp3s can be converted back into a PCM format on install or at runtime ( although, of course, they will still be ''lossy''. )

Sampling at 22Khz means more than just losing the high end. Even though Nyquist tells us that this rate will sample up to 11Khz with no aliasing, the perceived sound is most certainly changed. This is why most ( all? ) audio sequencers now permit a sample rate of 96Khz despite the 20Khz limit on human hearing; and the increase in quality IS noticeable.

Share this post


Link to post
Share on other sites


of course, the difference is noticeable.

ie, a sample rate of 44kHz means that you have about
8 samples for a complete wave at 6 kHz, which even my 80 year old
grandma can hear. EIGHT lousy samples to describe a complete period... how accurate...
( I think about 6 kHz is the upper border of frequencies that music intruments
produce as "ground frequency", so not only the multiples of the freqs are described
inaccurate (sorry, I don''t know the correct terms in english))
And so many people don''t see this, and say things like
"44kHz already is double of the freq audible to human, why use higher ?"
They should just think a bit about it...

BTW, mp3 with less than 256kbps sound awful to me,
and even 256 or higher sometimes turn hi-hat clicks into typewriter hits.
Those who say >=128kbps will have no artifacts, and sound as good as CD,
probably visit clubs too often
(at many clubs my ears ache when I stand in front of the entrance ,
many play music insanely loud nowadays, no ten horses will get me in there...)

Share this post


Link to post
Share on other sites
The Nyquist Theory:

With a sampling rate of X, any wave up to frequency of X/2 can be perfectly reconstructed.

Note the bold word.

Now, if you sample at twice the maximal hearing frequency of the human ear, you''ll be able to reproduce exactly what you''re hearing. There''s no ifs or buts about it, pure, simple, scientific fact.


Or is it?

http://www.byte.com/documents/s=527/BYT20010105S0001/

Note that the fault does NOT lie in the sampled signal. From a theoretical standpoint, 44.1Khz is enough. It''s the reconstruction that buggers up. Forcing reconstruction to operate at higher frequencies (such as 48Khz or even the dreaded 96Khz) allows the reconstruction filter to be REALLY bad, and yet never actually encroach upon what the human ear picks up.

So, by having higher sampling rates, you''re basically forcing hardware manufacturers to keep up with you, which can be a good thing.

Share this post


Link to post
Share on other sites
quote:
Original post by MadKeithV
The Nyquist Theory:

With a sampling rate of X, any wave up to frequency of X/2 can be perfectly reconstructed.





I heard of this.
I doubt that you reproduce a complete wave period, let''s say a sine just from
0...2pi, with two sample values!

What do you understand by the word "perfectly" ?
May be "acceptable".
It may sound ok, but is it "exactly what you''re hearing" ?

The human ear is far more accurate than many think. In fact, it''s the most
accurate sense humans have.

you said:
"There''s no ifs or buts about it, pure, simple, scientific fact"

well, I would not give all things that were once researched by scientist
the state of "the word of god".

at my uni, there''s a professor that doubts several of todays "facts" concerning about how
humans "really" hear, and he''s getting more people convinced of his way of viewing.

When I''m at home, I''ll post the link to his page, it''s really interesting.
(I don''t remember the url)

One thing he said, which I just remember, is:
" ''facts'' can''t be simple enough for marketing "




however, I found this at prorec.com:
"
A little known aspect of Nyquist theory is that integration over all samples is required to produce the original waveform. The Nyquist frequency is an asymptotic limit, which
is approached, but never reached."

"
Since our ears don''t integrate over all time, there has to be a gradual approach to this failing point. I think that human perception places a window on the math, and therefore
forces a gradual degredation in reproduction as the Nyquist frequency is approached. A rule of thumb we used when I was a co-op was to make the sampling rate 2.5x the
highest frequency of interest. This way the sampling artifacting would be minimized.
"

Well, they use 2.5, but it''s a rule of the thumb .




Share this post


Link to post
Share on other sites
quote:
Original post by UnshavenBastard
What do you understand by the word "perfectly" ?



Exactly what it says. An indistinguishable reproduction of the original input wave.

quote:
Original post by UnshavenBastard
May be "acceptable".
It may sound ok, but is it "exactly what you''re hearing" ?


Yes.


quote:
Original post by UnshavenBastard
well, I would not give all things that were once researched by scientist the state of "the word of god".


Now you''re just crapshooting. If you''re going to disprove me, disprove me. The Nyquist theorem is very mathematically sound.

quote:
Original post by UnshavenBastard
at my uni, there''s a professor that doubts several of todays "facts" concerning about how humans "really" hear, and he''s getting more people convinced of his way of viewing.



You''re suddenly confusing a whole bunch of things at once. The Nyquist theorem has NOTHING to do with human hearing. Its about sampling and reconstruction. It is peripheral - it might be that human hearing achieves an accuracy of Y, rather than X, but that doesn''t change the fact that a Nyquist rate of 2Y would be sufficient for an audibly perfect reconstruction.

quote:
Original post by UnshavenBastard
When I''m at home, I''ll post the link to his page, it''s really interesting.


I''m interested in it - psychoacoustics can be very important. But that doesn''t change the Nyquist theorem.


quote:
Original post by UnshavenBastard
One thing he said, which I just remember, is:
" ''facts'' can''t be simple enough for marketing "


Translated to "if we can put a larger number on the box, people will think it''s better." That actually goes against your argument



quote:
Original post by UnshavenBastard
A little known aspect of Nyquist theory is that integration over all samples is required to produce the original waveform. The Nyquist frequency is an asymptotic limit, which
is approached, but never reached."



Which is reconstruction. Did you even read all the way through my post? You didn''t, did you... it''s exactly this part that leads to the quality of the reconstruction filters. An infinite filter is impossible, so it all depends on how large (and accurate) the reconstruction filter is. The higher the sampling rate, the less sensitive the process is to errors within a fixed bound.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

hey, however, the url you posted, interesting

what CD players do to the original signal...

it''s quite obvious they do distort, but I never thought about it


he (trevor) said this:
''''96 KHz is not twice as good as
48,000, it is approximately 10 times better. Even 48 KHz is
twice as good as 44.1 KHz. It was on this basis that I described
the 96-Khz sampling rate as "overkill." ''''


well, how can one say then, with sample rate X, freqs up to Y can be "perfectly"
reproduced, if OTOH one says rate Z is x times better than X ?

or maybe I just have a wrong understanding of the word "perfectly",
well, as you surely have noticed, english is not my native language.
My understanding of the word "perfectly" is, that it can''t be better.
Like 100 of 100 percent...


- unshaven



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by MadKeithV
[quote]Original post by UnshavenBastard
What do you understand by the word "perfectly" ?





quote:
Original post by UnshavenBastard
One thing he said, which I just remember, is:
" ''facts'' can''t be simple enough for marketing "


Translated to "if we can put a larger number on the box, people will think it''s better." That actually goes against your argument


ah, no, really not. when I thought of this, I meant such things like mp3 players that seem to sell as hell,
(cool that rhymes)
they say the remove frequencies not audible, and it was damn good quality, people buy it,
and seem to be satisfied with it. fine. I''m not, to me it sounds ugly, no matter
how much you turn active filters after the mp3 player on, it may sound fat then, fat but
"mutilated" somehow. hope you know what I mean.



Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
well, how can one say then, with sample rate X, freqs up to Y can be "perfectly" reproduced, if OTOH one says rate Z is x times better than X?



Because the human hearing needs to be factored in. Hm, I''ll try an analogy:
the speed limit is 120kmh. One car does 130kmh. Another does 1300kmh. Now, technically, the second car is 10*faster than the first. Yet each car will get to the destination in the same time, because you are not allowed to go faster than 120kmh anyway. (disregarding the fact that you can drive illegaly fast )

So basically - 96Khz will allow you to reconstruct a LOT more frequencies a lot more accurately than 44.1Khz, but all (most, really, see the reconstruction argument) of those frequencies will be outside of the range of human hearing - we can''t hear the difference, so it makes no difference.

That is, again, in theory. In practice, the "infinite integral" problem - or in other words the imperfect reconstruction filter, means that you better go slightly over the theoretical necessary maximum for audibly-perfect reconstruction. The article made the point that 48Khz was already twice as good as 44.1Khz, and therefore going all the way up to 96Khz would be overkill. But maybe overkill isn''t a bad thing if it greatly improves the margin of error.

Share this post


Link to post
Share on other sites

you certainly know I can''t (and don''t want to) disprove this theorem

what I wanted to say is, of course you''re not storing the actual sound
exactly, that''s why it''s called "sampling". for "my taste", 8 samples
for 6 kHz sounds a bit low. well, theoretically , it may be possible to reproduce
the original wave from 8 sample points, (in theory always everything works )
as you surely and correctly suppose,
I don''t know enough of the theory, you only have to take a look a the music & sound forum,
I recently started a thread for information on wave synthesis (I like it better backwards )

but, what seems very obvious to me (maybe I am wrong), that, if you have more
samplepoints, exact reproduction is easier to achieve, and chances to fail are lower.

maybe the way how I said things is a bit confusing and mixed, you''re not the only one
who has difficulties to understand what exactlly I mean (the difficulty is on my side, I know...)

Share this post


Link to post
Share on other sites
quote:
Original post by UnshavenBastard
but, what seems very obvious to me (maybe I am wrong), that, if you have more samplepoints, exact reproduction is easier to achieve, and chances to fail are lower.



Actually, you aren''t wrong. More samples does give you more fault tolerance - the theory says you don''t need that much, but in practice you can be a LOT sloppier in your calculations if you have more sample points. That''s the really-simplified version of the reconstruction filter problem


Share this post


Link to post
Share on other sites
Hey there, i''m not really up on the nitty gritty of it all, but also 96khz has got the -193db noise floor, whilst 44 has the -96db, now i know we''re talking real subtle, but it''s inevitable that the 96khz has a far greater dynamic range and handles lower input and dynamics a lot better, you guys with me on that one? Not to mention the way you can overkill with a higher bit rate, leaving alot of room for more punchy recordings, which then, can be mastered into 44khz recordings with little strain.



Purple Hamster
Helped and be helped!

Share this post


Link to post
Share on other sites

hey, madkeith5, here''s the promised link:

http://iesk.et.uni-magdeburg.de/~blumsche/

I haven''t watched this page yet, he gave me the link
2 weeks ago. "Auditory function" is what he told me to
take a look at.

FU**!!! another thing that I found on the piece of paper
that he gave me: 18.06.2002.
two days ago, and I forgot it!!! dammit!

a guy called Greenberg visited the city where my uni is,
the prof told me he was an authority on this subject,
I could have listened to him, but I forgot it!!!
DAMMIT!!!

UnshavenBastard

...very annoyed....




Share this post


Link to post
Share on other sites
Question:

Something, that just came to my mind, concerning the
X/2 thing:

If you sample a frequency 1/2 the sample rate,
you have 2 sample points for a complete wave.
Say, it's THE basic wave: sine.
If your two sample points hit the two extrema, you're fine.
If the first hits 0, and the second pi or 2pi, the
value is zero for both points. It could be a sine wave
with a very high amplitude, but you won't be able to
reproduce it.
Well, and if you have a slightly amplitude modulated
sin, where the amplitude of the 1st half wave is 1.0,
an the amplitude of the 2nd half wave is 0.5
1st sample point hits the first extremum, 2nd 2pi.
An unmodulated sine would have the same values, 1 and 0.

Hitting "bad positions" can happen all the time, because
your sampling is not phase-synchronized to any of the
"wild" frequencies to be sampled.

So there's many of a sound that probably is not
reproducable after sampling, or gets totally wrong "reproduced",
because the obtained sample values are f... up.


Any comments/correction ?



[edited by - UnshavenBastard on June 22, 2002 7:23:30 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hmm. I think over analyzing the intricacies of nyquist theorem can be counterproductive. But that''s just me...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

in what way is this counterproductive?
what can happen if someone reads my previous post?
he/she ignores it? corrects me? uses a higher sample rate than
2*maxfreq ?

tell me why this is counterproductive.

- unshaven

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yikes, calm down brotha. That was a light-hearted comment towards the whole thread - sometimes overanalyzing rudimentary theories causes one to lose sight of the original objective. Didn''t mean to strike a nerve.

Share this post


Link to post
Share on other sites

It''s sometimes funny to see how comments get
interpreted, when they''re only read, and the voice
doesn''t get transmitted

You didn''t "srike a nerve", I just wondered why
you said "counterproductive", as if my thought
would cause an earthquake

in general I don''t think it''s so bad to discuss something
somehow related to the subject of a thread, when the
original question has gotten answered.


Share this post


Link to post
Share on other sites
quote:
Original post by UnshavenBastard
If you sample a frequency 1/2 the sample rate,
you have 2 sample points for a complete wave.
Say, it''s THE basic wave: sine.
If your two sample points hit the two extrema, you''re fine.
If the first hits 0, and the second pi or 2pi, the
value is zero for both points. It could be a sine wave
with a very high amplitude, but you won''t be able to
reproduce it.

I''m not entirely sure what you''re saying, since I never deal in terms of pi or whatever, but I think you might be missing the crucial point.

Note that the frequency you can sample is up to the sampling rate divided by 2, but not including the sampling rate divided by two exactly.

Now, with that in mind, if your sampling rate is more than double the frequency of what you''re recording - no matter by how small an amount - then you are guaranteed at least 3 samples along the wavelength. So even if 2 of those are zero, the third gives you the information you need.

Let''s imagine you''re sampling at 44KHz, and the tone you''re recording is 21999KHz (just under half, as required). If your first sample hits the zero at the start of the sine wave before it goes up to full amplitude, the next sample will be just before that wave dips back down below zero towards negative amplitude. The sample after that will come just before the wave repeats and will be just below zero, and so on. So the values might look like: 0, 0.001, -0.002, 0.003, -0.004, etc. Given these values, you have enough information to reconstruct the wave, both in terms of frequency and in terms of amplitude. You do need to read several values in order to work it out, but the information is there.

Of course, in the real world, samples can''t store fractional parts and therefore the sound degrades compared to the original pure tone. But that is a quantisation error rather than an aliasing error, which is what the Nyquist theorem addresses. This is why cd-quality sound is not perfect to all human ears - although the 44KHz sampling rate is high enough to reduce pretty much all audible aliasing, 16 bit quantisation is not high enough to make all the quantisation errors unnoticable. (Ironically, the human ear only needs about 17 bits, but that is not a very computer-friendly value.)

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

Share this post


Link to post
Share on other sites

  • Advertisement