         
         for i in 1..<itemsCount+1 {
           let num = NSString(format: "%02d", isLeft ? itemsCount+1 - i : i) // 左車輪の音だったら反転し、２桁で0埋め
-          let url = NSBundle.mainBundle().pathForResource("tones/\(toneDir)/\(num)", ofType: "wav")!
-          let audioFile = AVAudioFile(forReading: NSURL(fileURLWithPath: url), error: nil)
+          let url = Bundle.main.path(forResource: "tones/\(toneDir)/\(num)", ofType: "wav")!
+          let audioFile = AVAudioFile(forWriting: URL(fileURLWithPath: url), settings: nil)
           audioFiles += [audioFile]
           
           let player = AVAudioPlayerNode()
-          engine.attachNode(player)
+          engine.attach(player)
           engine.connect(player, to: mixer, format: audioFile.processingFormat)
           player.volume = 9.0
           

  
  @IBAction func tapToneName(_ sender: UIButton) {
    let initial: Int = toneDirs.index(of: toneNameBtn.titleLabel!.text!)!
    ActionSheetStringPicker.showPickerWithTitle("Tone", rows: toneDirs, initialSelection: initial, doneBlock: {
      picker, value, index in
        let key: String = "\(index)"
        self.initPlayers(key)
        return
    }, cancelBlock: { ActionStringCancelBlock in return }, origin: sender)
  }
  
  // AVAudioPlayerNode の生成やAudioFileの設定

            let _slider: UISlider = beaconUI?[1] as! UISlider
            
            if _switch.isOn {
              if accuracy_min == nil || Float(_beacon.accuracy) < accuracy_min! {
                accuracy_min = Float(_beacon.accuracy)
                nearestBeacon = beaconName
              }
