Algorithms for Melody Search and Transcription