Organists are one of the very few groups of musicians who have to learn not to listen to what they are playing, because (except for situations where a detached playing console is in the middle of the building) what they hear while playing has no resemblance to what the audience is hearing.
Even with a relatively small pipe organ with the console "built in" to the instrument, what the organist hears is heavily muffled by the structure of the organ case (which is designed to project the sound over his/her head!) and the tonal balance of different stops will be distorted by their different physical locations in the instrument.
If you are faced with an unfamiliar instrument, one option is simply to listen to someone else playing, from the audience's position. At least with modern communication technology like cellphones, you don't have to try to shout instructions to each other over the noise of the instrument!
The technical solutions to the problem are mainly articulation and registration. If you ensure the frequency spectrum if the "melody" and "accompaniment" are sufficiently different, the melody will be heard as such. This is actually a similar technical problem to mixing recorded music.
The non-technical solution is to choose your music carefully. Specifically, music written by composers who were also organists is more likely to work than arrangements of non-organ music made by non-organists. Whatever period of music you choose, Bach, Couperin, Mendelssohn, Franck, Widor, Messiaen, etc wrote "organ music that works" - and often is very hard to arrange successfully for any other medium.