Outside the elegant neoclassical building that the Royal Scottish Academy (RSA) has inhabited in Edinburgh city centre since the early 19th century, hundreds of people were dancing in the sunshine to I'm Gonna Be (500 Miles) by The Proclaimers.

This joyful sight and sound was part of a mass rehearsal for the film version of the musical Sunshine On Leith, currently filming in and around Edinburgh.

With this feel-good factor at my back, I headed into the RSA to take a look at its 187th Annual Exhibition, which opens to the public today and includes paintings, sculpture, film, printmaking, photography and installation alongside work by some of the country's leading architects. The sunshine followed me, streaming in through the large sky windows and shedding light over these 300 assembled artworks.

As I wandered from room to room, looking at work spanning 4000 years, the title of the curated section of this exhibition, Between The Late And Early, started to made perfect sense. As a species, we are all between the late and early, juggling the temporal world with the physical and the constant state of flux in between.

Until three years ago, the RSA's annual exhibition was based on the open submission of work by all comers, but is now part curated work by invited artists and part RSA members' exhibition. Members are allowed to submit up to four artworks for the latter. For this visitor, the change represents a more coherent viewing experience. The annual exhibition covers both art and architecture in 13 different galleries and, for this year's show, it feels is as if there is a game of two halves going on, with some players moving effortlessly between the teams.

Convenor Edward Summerton has invited 34 artists from the RSA's membership, the broader Scottish arts community, Europe and the US. He has also made a series of inspired selections from the RSA's capacious archives as well as the forgotten corners of museum storerooms around Scotland. This provides a startling counterpoint to work by the likes of Dalziel + Scullion, ROGER&REID (winner of the RSA Morton Award), Madeline Mackay (RSA Barns Graham Travel Award) and Anne Murray (RSA William Littlejohn Award).

Invited artists also include Bafta award-winner John Maclean, who has a film work called Beta Band – Inner Meet Me on show, and Gabriela Fridriksdottir, who has collaborated extensively with the musician Bjork. She has created a series of strange creatures fashioned from a mix of plaster, hay, bones, hoof nails, sawdust, string and more, which will, I predict, scare the bejesus out of any passing children. Interspersed throughout, there is poetry from Kenneth Steven, on its own in a simple frame and also as part of a wondrous collaboration with Will Maclean called The Island Road.

Sourced objects include Neolithic stone balls from the collection of Perth Museum and Art Gallery, and a pair of horrific iron witches' branks, used in medieval Scotland to punish women suspected of witchcraft, on loan from the collection of Dundee Art Galleries and Museums. There are also some exquisite illustrated paintings, prints and books from the RSA Collections by artists such as William Blake, Gustav Dore and John Martin. The Blake illustrations of the Book of Job graphically depict the biblical figure's trials at the hands of Satan and set up a visionary, otherworldly template for the entire exhibition.

Some of the invited artists in the curated section cross over into the members' section of this exhibition deliberately, while others, such as Willie Rodger, have work which simply is between the late and the early without even trying. His beautifully spare and darkly comic linoprint, Vacancy, sets up a scene which shows an empty pulpit waiting to be filled. This issue is at the heart of the General Assembly of the Church of Scotland, taking place further up The Mound during my visit.

Also on show are works by three RSA members who have died recently, Bill Scott PPRSA, George Wyllie RSA and Antoni Tapies HRSA. Wyllie's majestic spire, Studio, sits between two David Mach sculptures, one of a prowling big cat called Spike made from steel and coat hangers and a bust of Robert Burns fashioned from pins and foam. Like much of the assembled work, it's an odd fit. But it works.

RSA 187th Annual Exhibition, Royal Scottish Academy, The Mound, Edinburgh (www.royalscottishacademy.org, 0131 225 6671) until July 2