             continue
 
   noteOn: (event) =>
+    if @readyTimbres isnt @timbresLength
+      return
     # console.log(event.code)
     switch (@workMode)
       when "Music Box Mode"

              @sources.push(source)
          @i++
      when "Real Piano Mode"
        if event.code of @keysNotes
          @gainNode.gain.value = 1
          source = @context.createBufferSource()
          source.connect(@gainNode)
          source.buffer = @timbresAudio[@timbre][@keysNotes[event.code]]
          source.start(0)
          @sources.push(source)



  deactivate: () =>
    @subscriptions.dispose()

  loadSheets: () =>
    for sheetName in sheetsArray
      @sheets[sheetName] = JSON.parse(fs.readFileSync(
        path.join(__dirname, "sheets", sheetName)
      ))

  loadTimbre: () =>
    # Use two closure wrappers to save the status.
    # Because decodeAudioData() is an async method.
    for timbre of timbres then do (timbre) =>
      @timbresAudio[timbre] = []
      for pitch of timbres[timbre] then do (pitch) =>
        @context.decodeAudioData(base64Binary.decodeArrayBuffer(
          timbres[timbre][pitch].split("data:audio/ogg;base64,")[1]), \
          (audioBuffer) =>
            @timbresAudio[timbre][pitch] = audioBuffer
            ++@readyTimbres
        )
    for timbre of timbres
      for pitch of timbres[timbre]
        ++@timbresLength


  changeMode: () =>
    @workMode = atom.config.get("atom-code-music.workMode")
