             }
         }
         for i in 0..<changeWidth {
-            if(Int(index) + i < f0Array.count){
-                f0Array.remove(at: Int(index)+i)
-                f0Array.insert( y, at:Int(index)+i)
-                world_parameter!.f0[Int(index)+i+start] = Double(f0Array[Int(index)+i]!)
-            }
-            if(Int(index) - i>0){
-                f0Array.remove(at: Int(index)-i)
-                f0Array.insert( y, at:Int(index)-i)
-                world_parameter!.f0[Int(index)-i+start] = Double(f0Array[Int(index)-i]!)
-            }
-        }
-    }
+            if tapIndex + i < f0Array.count {
+                f0Array.remove(at: Int(tapIndex)+i)
+                f0Array.insert( y, at:Int(tapIndex)+i)
+                world_parameter!.f0[Int(tapIndex)+i+f0_start] = Double(f0Array[Int(tapIndex)+i]!)
+            }
+            if tapIndex - i>0 {
+                f0Array.remove(at: tapIndex - i)
+                f0Array.insert( y, at:tapIndex - i)
+                world_parameter!.f0[tapIndex - i + f0_start] = Double(f0Array[tapIndex - i]!)
+            }
+        }
+    }
+    
+    //flagに対応してボタンを押せるかどうかをまとめて変更
     func FuncAllTap(flag:Bool){
         recordButton.isEnabled = flag
         femaleButton.isEnabled = flag

        LoadWavFromPath(path: "vaiueo2d")
        loadEffectData(particlePath: maleStandPath!,shadowParticlePath: maleShadowPath!)
    }

    
    //すべてに共通するアプリスタート時の一番最初の設定
    func InitializeView(){
        //操作画面の設定
        standEffect = SKView(frame:CGRect(x: 0, y: HeaderFooter, width: Int(self.view.frame.width), height: AllViewY-HeaderFooter*2))
        //本UI画面の設定
        self.standScene = SKScene(size:CGSize(width:self.view.frame.width,height:CGFloat(AllViewY-HeaderFooter*2)))
        standEffect!.presentScene(standScene)
        //グラフの高さの設定
        graphViewHeight = AllViewY - HeaderFooter*2
    }
    //すべてに共通する画像系のデータ読み込み
    func loadingViewData(){
        //Stand背景の設定
        let backGround = SKSpriteNode(imageNamed:"background")
        self.standScene?.addChild(backGround)
        //self.view.sendSubview(toBack: background)
    }
    func loadEffectData(particlePath:String,shadowParticlePath:String){
        particle.removeFromParent()
        shadow.removeFromParent()

            buffers.append(buff)
        }
    }
    
    //WorldParameterの初期化
    func InitializeWorldParameter(wavName:String){
        f0_start = 0
        f0_end = 0
        //分析フェーズ
        let str = URL(fileURLWithPath: Bundle.main.path(forResource: wavName, ofType: "wav",inDirectory:"waves")!).absoluteString
        let arr = str.components(separatedBy: "///")
        world_parameter = execute_world(arr[1],toPath+"/output.wav",-1)
        
        Initializer(&world_parameter!,Int32(buffer_size))
        
        
        f0Length = Int((world_parameter?.f0_length)!)
        f0Array = []
        for i in 0 ..< f0Length{
            f0Array.append(CGFloat(world_parameter!.f0[i]))
        }
        xAxisMargin = view.frame.width/CGFloat(f0Array.count)
    }
    
    //再生用のAVAudio周りの初期化
    func InitializeAudio(file:AVAudioFile){
        audioEngine = AVAudioEngine()
        playernode = AVAudioPlayerNode()
