Author Topic: Music in 4k?  (Read 6805 times)

0 Members and 1 Guest are viewing this topic.

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Music in 4k?
« on: January 07, 2009 »
Hello.

I am planning to do some 4k intro, I've started with some framework but I think I will need some help or suggestions concerning the sound. I know shit about sound coding. Before that I was using some music library to play a mod or mp3 and never thought about it. But for my 4k it's essential to start learning how to do it myself.

What I want to know is what kind of technique do most people use to generate and play music in 4k (Are they generating the instruments and the song? is it midi playback? do they use some instruments from the system or do they have to create them with code?). Is there a tutorial or example codes about this?

I don't know anything about it and I don't know where to start. But I see even 4ks from newcomers in the scene have music so it mustn't be that hard..
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Music in 4k?
« Reply #1 on: January 07, 2009 »
I suggest to have a look at kb's article which describes the basic concepts pretty well - for 4k you'll probably want take some shortcut, though.
Essentially you need a couple of oscillators, a lowpass-filter and lfos/envelopes to modulate pitch/volume/cutoff.
Most work will go into the usability.
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Music in 4k?
« Reply #2 on: January 08, 2009 »
@Optimus:
I am not an expert but i will try to tell you what i know about this...

Personally i think the best way (and the way most people are using afaik), is to generate the soundsamples yourself. Ofcourse you could use Midi (and GM.dls == DX WaveTable dll == sounds hears the same on any PC instead using Wavetables on the soundcards, which would end in different results when playing/hearing).

The GM.dls is a complete GeneralMidi Wavetable (and its a standard, every musician will/should know this!). You can go and use this GM.dls, by extracting needed instruments (waves) and use it for your own use. To get a overview what stuff is included in this GM.dls and how to play with it and extract datas, just take a look to this nice tool and play a bit with it: http://pouet.net/prod.php?which=30541

If you want create/generated your very own instruments (even portable to other OS if you want), you should learn some basics about sound and its generation. For example you should get the point, that you need different waveforms to generate all possible sounds you ever want....

Here you can see the needed Waveforms and its names:


You should know that their is a so called "pink noise" or often called "white noise" too... What is this? When watching TV and dont get any TV programm in... just only the black/white noise on screen, you can hear it... its the noise! At the first moment you dont or may not hear anything out of it, like a singing woman or any other tons... But at least, in white noise all waveforms are available and so its possible, that you could (theoretical) filter this noise and get a singing woman or any instrument... (this is the effect, when watching/listening very long to the tv noise and when you think you hear something inside this noise ^^)

If you want start generating the first Sin-Tone (its the easiest you should start with), you should take a look to the RIFF WaveHeader http://de.wikipedia.org/wiki/RIFF_WAVE how this looks like and what informations are stored in a WAV header... Next you could take a look to sndPlaySound API http://msdn.microsoft.com/en-us/library/ms713269.aspx... You could use this simple API to play the first generated stuff or for playing a complete generated tune (wave format)...

Sadly i am very busy atm and dont have so much time nor knowledge to help you atm... but i will try to find an very old experience myself, to generate any dirty sound :P  I will post here, even if the source is very old and really dirty source :P

Start things with a frequence of 44100 hz...  Create an Array where you will store your generated datas... for example SIN wave... (+32767 to -32767)....  0 means you will hear nothing, like the deadline ^^ Next try to play this Array (memory block) with sndPlaySound API...

hope this helps a bit for the first... good luck n best regards
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Music in 4k?
« Reply #3 on: January 08, 2009 »
Quote
You can find a closer explanation of these waveforms here and here.
The idea behind all this is that you can either construct a waveform from a sum of sine-waves (additive synthesis, also have a look at fourier transformation) or, which is computationally less expensive, use a waveform with a rich spectrum of harmonics (like saw and square) and remove the parts you don't need using filters (subtractive synthesis).
If you haven't incidentally studied singal-processing, constructing filters is a pretty complex field. For a start I'd recommend to grab some resources from musicdsp and play with them to get a basic understanding of what they do and how they work.
One major problem with subtractive synthesis is that your base-waveforms include harmonics which are beyond your sampling frequency (have a look at the nyquist theorem).
As the amplitudes of increasing harmonics are constantly falling, you'll internally work at some reasonable higher samplingrate and use a filter to make sure they don't add garbage to your signal.
When you've got that you're able to produce simple beeps. To make this musically interessting you'll need some lfos and envelopes to make your sound change over time.
To synthesize actual instruments from that I'd recommend to study the synth-secrets series which imparts a good understanding of how to create musically useful sounds from very limited resources.
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Music in 4k?
« Reply #4 on: January 08, 2009 »
@Optimus:
If you want to dive deep into sound programming you should read
the given links - but I guess this will require some time.

When I coded my little 4kb game and wanted to implement some
sound - I did the following:

- I searched on pouet for 4kb which come with source code
- Most of them have a soft synth system integrated
- I personally find it easier to learn from a working example
- Then you could try to manipulate it to your needs

If you want to make your life even easier - have a search for
4kb demotools. You might find something like this:

http://www.pouet.net/nfo.php?which=52038

Of course the quality of those might cannot compete with
other optimized synths and maybe even waste some bytes.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: Music in 4k?
« Reply #5 on: January 08, 2009 »
Thank you, it's all helpfull. Some of them need a lot of study but are interesting. Yesterday I was reading the kb articles. It's more complex stuff than what I might need but it was interesting for sure. I also found some frameworks I kept in my hdisk for 1k/4k/64k (those by iq/rgba) and some of them play a long sine using the sndPlaySound API function. It's good, I might try changing some things to see how sound changes.

I think I will follow this way, it's also interesting for me to learn something about sound synthesis and I am really eagier to understand the connection of visual/math with sound as I used to visualize maths in my mind in demo effects in the past. I might just need to read further in the docs to find the basics, how to generate the instruments by combining those four waves, scale the frequencies to make them play different notes and maybe thing of a very simply tiny pattern thing or something to play the sounds in order.

The buzzie thing sounds also interesting (if I want to make something fast and have no time for my own player). Maybe I'd download and see the source codes of some 4k intros. I am wondering how small code is needed to play a simple melody with a beat or something, the best way is to see those codes and get an idea.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Music in 4k?
« Reply #6 on: January 09, 2009 »
How upset do demo fans get if you use the samples from gm.dll?

Jim
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Music in 4k?
« Reply #7 on: January 09, 2009 »
Quote
How upset do demo fans get if you use the samples from gm.dll?
If you make them sound like a cheap midi-file they will thumb you down but if you use them wisely they won't notice anyway.
Personally I don't see a problem in using resources that are available.
Some years ago people were pissed when you used shaders or 3d-acceleration or even windows...
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: Music in 4k?
« Reply #8 on: January 09, 2009 »
Quote
How upset do demo fans get if you use the samples from gm.dll?
If you make them sound like a cheap midi-file they will thumb you down but if you use them wisely they won't notice anyway.
Personally I don't see a problem in using resources that are available.
Some years ago people were pissed when you used shaders or 3d-acceleration or even windows...


LOL

BTW, 'grats on winning the LED compo.

Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: Music in 4k?
« Reply #9 on: January 09, 2009 »
Quote
How upset do demo fans get if you use the samples from gm.dll?

I guess it will be the main reason for one or two thumbs down out of fourty, so it might not be important :)
Even in dos intros someone would say they are getting resources (taking the system font :) but nobody argues on that.
OpenGL would be like getting resources. Many 4ks might need d3dx9_xx.dll (I hate that one when I have to search for the dll) which is 2MBs big.
The funny part is when people use commercial MP3s and drive sceners crazy. I would like to use one of my favorite songs some day just to piss off people :)
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Music in 4k?
« Reply #10 on: January 09, 2009 »
So true ... ppl get upset by so much unimportant things
these days. Wonder if those ppl don't have other problems
to take care of.

Nevertheless, that's another story ...
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won: