im still a newbie to this so i kinda need an answer to this
This is a very broad question, but I think there are a few basic ideas for you to be aware of. The following won't be a formula to write a song, but rather an suggested approach for thinking about dissonance.
- Dissonance/Consonance can be expressed as a ratio between two pitch frequencies where simple ratios are consonant and complex ratios dissonant. Like
1:1for a unison which would be the consonance end of the spectrum, and
16:15for a minor second near the dissonant end of the spectrum.
- Other than the ratio method shown above there is no objective measure of dissonance/consonance. It depends on culture or a particular school of composition. A perfect fourth is considered dissonant in strict, Church style counterpoint, but to many modern listeners it's consonant. Keep this in mind when reading about dissonance. Many 'rules' about dissonance are specific to particular composing methods, mostly in strict classical style, but jazz has some concepts about avoid notes too relating to dissonance.
- Consonance is considered stable, dissonance unstable, and that has a basic connection with meter. At a very basic level, meter confirming music will put consonances on strong beats. Dissonances would happen on weak beats, for example before a barline a dissonance on beat 4 to a consonance on beat 1 of the next bar. Or, dissonances may happen between beats like with passing tones. The ebb and flow of dissonance/consonance in this metrical way helps create a forward impulse in music.
- Dissonance can be used deliberately for expressive purposes. There is a type of non-chord tone called an appoggiatura which is dissonant, but can be accented on a strong beat to create a kind of expressive tension. Another example is the dissonant diminished seventh chord which can be used to express surprise or fear, etc.
Notice in the last two points how dissonance can sometimes be sort of hidden and unaccentuated, but then at other times deliberately accentuated for expressive purpose. This is what makes dissonance a tricky topic. It isn't bad per se, but requires careful control and depends a lot of style.