I've been writing my own music a lot lately, but one thing really has me stuck and that's writing the time signature. I know that time signatures are based on the amount and duration of the notes within a measure, but how do you know which time signature to write if you don't know where to end each measure? The piece I'm working on now has mostly eighth notes in the left hand and mostly half or quarter notes in the right hand. How do I know where to end each measure and thus know which time signature to add? Sorry if this question isn't the clearest. If you need clarification please comment and ask; I just really would like to know. Thanks a million!
An important aspect of meter is that there is a hierarchy of pulses. In other words, some pulses will be more emphasized than others on account of this hierarchy. Most musicians call these more emphasized pulses the "strong beats."
Thus, if you don't know the time signature, determine where these "strong beats" are. What beats in the music are naturally emphasized to you? In the overwhelming majority of cases, these strong beats will be evenly spaced from each other; often they occur every 4 beats, but they could occur every 3, every 6, or any other distance from each other.
Each measure will thus begin with a strong beat, and the barlines will be placed at the end of each unit within the hierarchy. In other words, if the strong beats are 4 beats apart, the measure will begin on the strong beat and will last for 4 beats; you can place the barline after these 4 beats, and you'll find that the barline will be placed right before the next strong beat.
At that point, you have enough information to determine the time signature. (It sounds from your first two sentences that you know the theory behind it, so I'll leave this part up to you!)
Tapping your foot to the rhythm and beat of a song, provided it has a regular beat, will give you the PULSE. The next thing to do is listen carefully to the regular accented parts of that rhythm. With your own songs that may be easy, as you know which words are emphasised. They are often the beginning of a new line, and certainly the beginning of a new verse or chorus. Count along to the pulse, and each time there's an accented note, say 'one'. keep counting till the next 'one' has to be said. The biggest number you managed to get to should tell how many neats in one bar, thus the top number in the time sig. It will usually be either 2, 3 or 4. Occasionally 6 and rarely 5. If you had to count steadily, the bottom number will usually be 4, if the count was fast, it'll be 8.Give this a go, and report back, please!
A small caveat - sometimes a line will start before the louder word in a new line. It's called an anacrucis, and can be a red herring. You're looking for the emphasised note/word instead.
Generally what to look for in dividing up the beats of the piece is where the strongest stress falls on the melody.
(For anyone who's wondering, I am using Sibelius 7 notation software).
I've beamed all the quavers (eighth notes) together and removed the barlines to show how it looks before we subdivide it into beats and bars.
First things first, we find where the stress falls on the melody. (It's very easy to do this with text, but any piece of music has places where stress falls; generally you look for clues such as chord changes, important bass notes, or important notes in the melody.) In the next image, I've shown the chords below the left hand staff, and marked the important stresses in the melody with tenuto marks (line accents):
We can see here that a lot of these 'clues' seem to happen every two beats - each tenuto comes every two crotchet (quarter-note) beats, and most of these coincide with a chord change. We can therefore assume that 2 is important - we can therefore try delineating every two beats (I am using tick barlines at first, just in case we may want to change it):
This looks good. We could also try it in four if we wanted (not every stress is what we call 'primary stress', and so every second stress we found could be less stressed than the others):
but this (to my ears) seems a little weird - to me, every stress seems as important as every other, and so the first grouping worked better. (Note that this bit is more subjective and is open to interpretation.)
Therefore, I will draw in solid barlines to show that each bar will contain two crotchet (quarter-note) beats. Because each bar contains 2 beats, each of which is a crotchet or quarter-note, which is one quarter the length of a semibreve (or whole note), we can therefore put a time signature at the beginning of the passage, saying that it is in 2/4:
(I group quavers in 2/4 by beat, but how you group quavers is again up to you.)
A few things on this (particularly if your music is a little more complex):
Music doesn't always need a time signature (or even bar-lines). It's useful for ensembles, where multiple people need to keep together and follow the same pulse and numbers of bars, but from the sounds of things this is a solo piece, and as a result, you might not even need one.
Satie (one of my favourite composers) wrote a lot of music for piano which doesn't use time signatures or barlines. (His handwriting was also bonkers, and so his scores look really unique.) His suite 'Sports et Divertissements' is made up of 21 short pieces, none of which delineate time using barlines and time signatures.
A PDF of the score can be found here: https://imslp.nl/imglnks/usimg/3/35/IMSLP08174-Sports_et_divertissiments.pdf
Satie's music isn't the only music that does this - it's a fairly common thing to find both before the baroque period and from the late 19th century (particularly these days, when people are doing almost anything!)
Time signatures can change. There are so many pieces of music where times signatures change that picking out one example to exemplify them all is difficult. Leoš Janáček (a Czech composer and one of my favourites) was fascinated by the rhythms of human speech and folk music, and so his music is full of tuplets (more or fewer notes fitting into beats than normal) and time signature changes to accommodate the rhythms. Again a piano piece, his suite 'V mlhách' is full of incredibly nuanced time signature and tempo changes to accommodate these rhythms (particularly the last movement, which is just mind-bogglingly complex).
To take a slightly different stylistic route, the rock band Tool write songs with incredibly rapidly-changing time signatures - they just write the music and delineate the bars according to where stress falls and then add in time signatures to match (sometimes very odd ones - the band claim that their song 'Schism' is written in 6 and a half over 8, but an analyst claims instead that the song changes meter 47 times). No score, I'm afraid, and for some reason they aren't on Spotify, but there are plenty of their songs on YouTube if you don't want to buy an album of theirs.
Time signatures don't have to bear any resemblance to the stresses. In Benjamin Britten's opera 'Peter Grimes', there is a Passacaglia (a type of piece where variations build up over a repeating bassline). The bassline is eleven beats in length, but it is notated in 4/4 time (thereby coming in at two and three quarter bars long). This shortcoming is never rectified, and so each repeat starts one beat earlier in the bar than the previous one.
No PDF score for this, but here is a video of the opera with the short score of the passacaglia attached:
NB. The whole thing speeds up as well!
I hope that is a fairly comprehensive look at it - basically, the first part is how to do it if you want to do it traditionally, and the second part is all the alternatives if you don't.
Hope that helps!