Well, play a musical idea or a simple musical phrase and you're already on the right track. The riff is an essential part of any song. But so are other categories: the metrics, the rhythm, the chord progression...
A riff consists of repeated notes, but repeated notes do not automatically constitute a riff! So, this then begs the question:
What is a Riff?
I wrote in the blog post titled 15 of the Greatest Guitar Riffs of All Time that a guitar riff is "a catchy guitar motif or phrase, repeated multiple times".
Play a catchy phrase and you got yourself a good riff base. Repeat it, optionally introducing some variations. A repeated phrase then defines the riff.
When you play music of any genre it's inevitable that you also play riffs. As we move along, examples will be noted of iconic musical solutions in this regard.
Here I'll only note in passing that the sound of music is essentially - an enriched riff sound. And more often than not: a good song is also "a riff song".
Riffs in Classical Music
The term "riff" in classical music theory doesn't exist as such. What defines a musical composition mostly revolves around its form and harmonic progression.
So - technically - "classical music riffs" do not exist. Technically. Compared to popular music, the classical is significantly more strict. Still, this doesn't mean they are completely unrelated.
Good music is based on (as my professor would put it) "thematic economy". Any good music ever played is therefore based on introducing a theme and its variations. That in turn means an introduction of repeats of sorts.
The Surprise!
So, here's a plot twist: most classical music is based on a repeated riff! The riff itself is varied - but it's a repeated riff nonetheless. Musical riffs in a way originated in classical music!
Take any large ensemble composition, consisting of several movements. Each one of those movements is based on several riffs. At times on a single riff even - and that one in turn composed of very few notes.
And how about the repertoire composed for solo instruments? Take Bach's "Well Tempered Clavier" collections. What are the Preludes based on - and especially the fugues?! Isn't any fugue just a melodic riff played at the opening and repeated at many points throughout?
To conclude: classical music theory features extensive analysis of form. If observed in detail, parallels can be drawn with popular music in many contexts. What is known as a chorus in pop, can be found similarly installed within a classical Rondo form, for example.
The Blues
Well, a chorus isn't a part of a blues song (at least traditionally speaking). Or one might say: its a chorus throughout and thus doesn't feature a verse. :)
A standard blues song is basically a three chords song. Observed in a historical context, it typically consists of a repeated 8-bar or 12-bar form.
This in turn doesn't mean that songs are simple, boring or overly repetitive, of course. In fact as we all know they are filled with energy, always moving forward.
The Guitar
The guitar played an irreplaceable roll when it comes to the development of the genre. A riff here is almost by definition also a guitar riff. Guitar riffs, as the instrument is directly related to its roots, constitute the core of the riff base.
This in turn means that popular guitar music is in some way inevitably inspired by it, and so are the guitar riffs. Play many songs of multiple genres, and you'll encounter blues influences all over the place.
Jazz Riffs?
Good example of an alternative approach when it comes to riffs in general is found in jazz.
What is a riff in a jazz then?
Back in the day, jazz was based on popular music. A song's catchy melody or it's melodic riff was enough for it to be on the band's repertoire.
However, a "riff" here isn't the same as in other genres, as noted in the blog article linked above. Therein I wrote that "...a jazzman speaking of "best guitar riffs" might actually be referring to rhythmic sequences...".
Does Theory Really Say That?
Jazz music theory, like classical, speaks not of riffs. Guitar melody notes for example, as part of a solo improvisation are analysed with regards to the overall creativity.
Thus, a "guitar solo riff" would be assessed with regards to its musicality and originality. In other words, guitar riffs for example, in this context aren't ranked based on their repetitiveness or "catchiness".
The melody line of a jazz standard and the notes played during a solo serve different purposes. To play a song (especially one considered "a standard") is about repetitions only with regards to its form.
That's Why I Go For That Rock N Roll Music!
Well, Chuck Berry did anyway. :)
The most famous riffs played are a part of any aficionado's rock music library. Yes: rock music has the most well known riffs. Or simply put - the most famous riffs are rock riffs; the most memorable riff is a rock riff!
That's not to say that every song of this genre is a good one, of course. Talking about rock music history and its most memorable riffs, I'll just note that a good rock song is by definition based on a good riff.
The Guitar - Take Two!
A rock riff is almost always also a guitar riff (though some epic bass and keyboard riffs exist too!). Take the more popular Led Zeppelin songs for example, and you're sure to find epic bass and guitar riffs.
The riff in rock music is often defined by the subgenre in question.
The opening lead line of a melodic ballad often serves as an anchor. In punk rock though, the rhythm itself is what the melody is to a rock ballad song. Play a sequence of a few power chords and you got yourself a base for good punk rock riffs. However... let's not forget that memorable riffs are more than simple repeated chords on the rhythm guitar!
What Defines What?
The riff itself (at least at times) defines the song's subgenre. Take Ritchie Blackmore and his "Smoke On The Water" riff, for example. It alone spells "hard rock" from beat one.
Yeah; even thinking of Deep Purple's guitar riffs inevitably leads to mentioning the one found in "Smoke On The Water". It is a song whose guitar riff is among the most popular riffs ever! More than that even - the "Smoke On The Water" riff is often regarded as "the riff of riffs".
Furthermore, a rock song will often contain transitions in the character of the music.
The Transitions
At the very beginning, Enter Sandman is quite a melodic song. Seems like Lars is there not to play drums but just a single cymbal. But the riff serves as a base for adding "roughness" to the song later.
Another lovely example of transitioning based on a melodic riff is found in "Stairway to Heaven" of course. This Led Zeppelin riff is a perfect example of how a ballad doesn't have to remain a ballad throughout.
The Touch
There's also the personal touch. The riffs of Jimmy Page will sound less rhythmical, when compared to the Chuck Berry riffs. But one might argue that they are definitely more melodic or colorful...
There's also influence, of course. Some of the bass rhythm played in Dave Davies' (The Kinks) songs resemble the bass riff of "Seven Nation Army". Great riffs were historically coming from this source (The Kinks' fans opinions differ on what riff was written by whom - but let's not quibble:).
Other Popular Genres
In popular music, songs typically feature a verse and a chorus. At times also a bridge is present, along with a pre-chorus.
Popular songs are usually based on melodic riffs. A verse riff leading into the chorus is found quite often as well. When talking about a "pre-chorus", people actually often think of that.
We've seen that a repeated musical phrase defines a riff. This is especially true in hip hop music.
Hip Hop... Simple At Places..!
In hip hop, you often hear riffs based on a single short musical phrase. In fact, riffs are the simplest here! And as the attention is to be aimed at the lyrics, it's only natural for it to be so.
Consider Dr. Dre's opening riff of "Still D.R.E". An exceptionally famous riff and perhaps the most well known one in this regard. No laity, no laziness here. In the context of producing (hip hop or otherwise) Dr. Dre knows very well what he's after and what he's doing!
The Rest of the Field
Well, we've mentioned hip hop as the pinnacle of riff simplicity. We had an in-depth look into rock, where riffs come in every shape or form imaginable. We spoke also of classical music, where riffs are at the basis of all variations.
Going further, there isn't much else to be said about other popular genres or pop music in general. At least when it comes to riffs. What was said thus far is applicable to the rest of the field as well.
...And Beyond Still...
Inevitably, you'll be listening to a lot of guitar music. Learn guitar riffs. Sneak in what you already know from earlier (a few Deep Purple riffs; skip "Smoke On The Water" if in a guitar store:).
While any Deep Purple song is a good riff source, to play a great riff you don't need to stick dogmatically to what's already known.
Listen to a song or even just the chorus of the song. As iconic as the "Whole Lotta Love" riff is, there are quite epic riff songs in the other popular genres too!
Play music, listen to music, listen to riffs, Explore! Great examples exist all around and in due time you'll compose your own!