         if 0 < layeredTones.count {
           let filePath = Bundle.main.path(forResource: "tones/\(toneDir)/layered/\(file)", ofType: "wav")!
           let fileURL = URL(fileURLWithPath: filePath)
-          let audioFile = AVAudioFile(forWriting: fileURL, settings: nil)
-          let audioFileBuffer = AVAudioPCMBuffer(PCMFormat: audioFile.processingFormat, frameCapacity: UInt32(audioFile.length))
-          audioFile.readIntoBuffer(audioFileBuffer, error: nil)
+          let audioFile = AVAudioFile(forReading: fileURL)
+          let audioFileBuffer = AVAudioPCMBuffer(pcmFormat: audioFile.processingFormat, frameCapacity: UInt32(audioFile.length))
+          audioFile.readIntoBuffer(audioFileBuffer, frameCount: nil)
           let player = AVAudioPlayerNode()
           engine.attach(player)
           engine.connect(player, to: mixer, format: audioFile.processingFormat)
           player.volume = 0.0
-          player.scheduleBuffer(audioFileBuffer, atTime: nil, options:.Loops, completionHandler: nil)
+          player.scheduleBuffer(audioFileBuffer, at: nil, options:.loops, completionHandler: nil)
           layeredPlayers += [player]
         }
       }

    
    // wavファイル以外は無視
    items = items.filter { (name: String) -> Bool in
      var regex = NSRegularExpression(pattern: ".wav$", options: NSRegularExpression.Options.allZeros, error: nil)
      return regex?.firstMatchInString(name, options: NSMatchingOptions.allZeros, range: NSMakeRange(0, name.count)) != nil
    }
    
    let itemsCount = items.count

        for i in 1..<itemsCount+1 {
          let num = NSString(format: "%02d", isLeft ? itemsCount+1 - i : i) // 左車輪の音だったら反転し、２桁で0埋め
          let url = Bundle.main.path(forResource: "tones/\(toneDir)/\(num)", ofType: "wav")!
          let audioFile = AVAudioFile(forReading: URL(fileURLWithPath: url))
          audioFiles += [audioFile]
          
          let player = AVAudioPlayerNode()
