浏览代码

add patterns

woelper 4 年之前
父节点
当前提交
a9c9ea3cfa
共有 6 个文件被更改,包括 382 次插入87 次删除
  1. 159 0
      patterns/cold sweat.pat
  2. 59 59
      patterns/funky drummer.pat
  3. 149 0
      patterns/impeach the president.pat
  4. 2 2
      sampler.ini
  5. 12 11
      src/base.rs
  6. 1 15
      src/main.rs

+ 159 - 0
patterns/cold sweat.pat

@@ -0,0 +1,159 @@
+{
+  "name": "cold sweat",
+  "repeat": 1,
+  "bpm": 416,
+  "xsize": 16,
+  "ysize": 3,
+  "sounds": {
+    "8,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "14,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "0,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "15,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "4,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "12,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "10,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "6,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "10,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "2,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "0,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "12,2": {
+      "name": "ride_bell2.wav",
+      "location": "media\\cc0\\ride_bell2.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "7,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "8,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "4,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    }
+  }
+}

+ 59 - 59
patterns/funky drummer.pat

@@ -1,13 +1,13 @@
 {
   "name": "funky drummer",
-  "repeat": 0,
+  "repeat": 1,
   "bpm": 416,
   "xsize": 16,
   "ysize": 3,
   "sounds": {
-    "11,2": {
-      "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+    "7,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -15,9 +15,9 @@
       "active": false,
       "speed": 1.0
     },
-    "2,2": {
-      "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+    "9,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -25,9 +25,9 @@
       "active": false,
       "speed": 1.0
     },
-    "10,2": {
+    "8,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -45,9 +45,9 @@
       "active": false,
       "speed": 1.0
     },
-    "0,0": {
+    "6,0": {
       "name": "kick_edm.wav",
-      "location": "media\\cc0\\kick_edm.wav",
+      "location": "media\\cc0\\kick_rough.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -55,9 +55,9 @@
       "active": false,
       "speed": 1.0
     },
-    "6,0": {
-      "name": "kick_edm.wav",
-      "location": "media\\cc0\\kick_edm.wav",
+    "11,2": {
+      "name": "hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -65,9 +65,9 @@
       "active": false,
       "speed": 1.0
     },
-    "15,1": {
-      "name": "snare_jungle.wav",
-      "location": "media\\cc0\\snare_jungle.wav",
+    "7,2": {
+      "name": "hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -75,9 +75,9 @@
       "active": false,
       "speed": 1.0
     },
-    "3,2": {
+    "4,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -85,9 +85,9 @@
       "active": false,
       "speed": 1.0
     },
-    "0,2": {
+    "10,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -95,9 +95,9 @@
       "active": false,
       "speed": 1.0
     },
-    "7,2": {
+    "5,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -105,9 +105,9 @@
       "active": false,
       "speed": 1.0
     },
-    "9,2": {
-      "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+    "10,0": {
+      "name": "kick_edm.wav",
+      "location": "media\\cc0\\kick_rough.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -115,9 +115,9 @@
       "active": false,
       "speed": 1.0
     },
-    "6,2": {
+    "9,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -125,9 +125,9 @@
       "active": false,
       "speed": 1.0
     },
-    "1,2": {
+    "14,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -135,7 +135,7 @@
       "active": false,
       "speed": 1.0
     },
-    "7,1": {
+    "15,1": {
       "name": "snare_jungle.wav",
       "location": "media\\cc0\\snare_jungle.wav",
       "volume": 1.0,
@@ -145,9 +145,9 @@
       "active": false,
       "speed": 1.0
     },
-    "12,2": {
-      "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+    "2,0": {
+      "name": "kick_edm.wav",
+      "location": "media\\cc0\\kick_rough.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -157,7 +157,7 @@
     },
     "13,0": {
       "name": "kick_edm.wav",
-      "location": "media\\cc0\\kick_edm.wav",
+      "location": "media\\cc0\\kick_rough.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -165,9 +165,9 @@
       "active": false,
       "speed": 1.0
     },
-    "12,1": {
-      "name": "snare_jungle.wav",
-      "location": "media\\cc0\\snare_jungle.wav",
+    "3,2": {
+      "name": "hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -175,9 +175,9 @@
       "active": false,
       "speed": 1.0
     },
-    "2,0": {
-      "name": "kick_edm.wav",
-      "location": "media\\cc0\\kick_edm.wav",
+    "6,2": {
+      "name": "hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -185,9 +185,9 @@
       "active": false,
       "speed": 1.0
     },
-    "5,2": {
+    "1,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -195,7 +195,7 @@
       "active": false,
       "speed": 1.0
     },
-    "9,1": {
+    "12,1": {
       "name": "snare_jungle.wav",
       "location": "media\\cc0\\snare_jungle.wav",
       "volume": 1.0,
@@ -205,9 +205,9 @@
       "active": false,
       "speed": 1.0
     },
-    "14,2": {
+    "0,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -215,9 +215,9 @@
       "active": false,
       "speed": 1.0
     },
-    "4,2": {
+    "2,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -225,9 +225,9 @@
       "active": false,
       "speed": 1.0
     },
-    "8,2": {
+    "15,2": {
       "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -235,9 +235,9 @@
       "active": false,
       "speed": 1.0
     },
-    "10,0": {
-      "name": "kick_edm.wav",
-      "location": "media\\cc0\\kick_edm.wav",
+    "12,2": {
+      "name": "hihiat_closed.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -245,9 +245,9 @@
       "active": false,
       "speed": 1.0
     },
-    "11,1": {
-      "name": "snare_jungle.wav",
-      "location": "media\\cc0\\snare_jungle.wav",
+    "0,0": {
+      "name": "kick_edm.wav",
+      "location": "media\\cc0\\kick_rough.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,
@@ -255,9 +255,9 @@
       "active": false,
       "speed": 1.0
     },
-    "15,2": {
-      "name": "hihiat_closed.wav",
-      "location": "media\\cc0\\hihiat_closed.wav",
+    "11,1": {
+      "name": "snare_jungle.wav",
+      "location": "media\\cc0\\snare_jungle.wav",
       "volume": 1.0,
       "roll": 0,
       "rollrate": 0,

+ 149 - 0
patterns/impeach the president.pat

@@ -0,0 +1,149 @@
+{
+  "name": "impeach the president",
+  "repeat": 1,
+  "bpm": 416,
+  "xsize": 16,
+  "ysize": 3,
+  "sounds": {
+    "0,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "4,1": {
+      "name": "snare_organic.wav",
+      "location": "media\\cc0\\snare_organic.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "6,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "12,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "14,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "8,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "14,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "7,0": {
+      "name": "kick_rough.wav",
+      "location": "media\\cc0\\kick_rough.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "4,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "0,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "12,1": {
+      "name": "snare_organic.wav",
+      "location": "media\\cc0\\snare_organic.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "2,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "8,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    },
+    "10,2": {
+      "name": "hihiat_real.wav",
+      "location": "media\\cc0\\hihiat_real.wav",
+      "volume": 1.0,
+      "roll": 0,
+      "rollrate": 0,
+      "trim": 0.0,
+      "active": false,
+      "speed": 1.0
+    }
+  }
+}

+ 2 - 2
sampler.ini

@@ -39,12 +39,12 @@ Size=300,100
 Collapsed=1
 
 [Window][pattern]
-Pos=9,157
+Pos=8,157
 Size=684,283
 Collapsed=0
 
 [Window][patterns]
-Pos=400,140
+Pos=437,13
 Size=324,186
 Collapsed=0
 

+ 12 - 11
src/base.rs

@@ -54,11 +54,11 @@ impl Sound {
         })
     }
 
-    pub fn reload(mut self) {
-        if let Ok(s) = Sound::new(&self.location.to_string_lossy()) {
-            self.data = s.data;
-        }
-    }
+    // pub fn reload(mut self) {
+    //     if let Ok(s) = Sound::new(&self.location.to_string_lossy()) {
+    //         self.data = s.data;
+    //     }
+    // }
 
     pub fn reload_data(&self) -> Result<Sound, std::io::Error>{
         Sound::new(&self.location.to_string_lossy())
@@ -69,7 +69,7 @@ impl Sound {
             Sound {
                 data: self.data.clone(),
                 ..Default::default()
-            })
+        })
     }
 
     pub fn decoder(self: &Self) -> Decoder<Cursor<Sound>> {
@@ -182,7 +182,7 @@ impl Pattern {
             Ok(f) => {
                 serde_json::from_reader(BufReader::new(f))
                     .map_err(|e| e.to_string())
-                    // .map(|p: Pattern| p.reload_sounds( ))
+                    .map(|mut p: Pattern| p.reload_sounds( ))
             }
             Err(e) => Err(e.to_string())
         }
@@ -211,18 +211,19 @@ impl Pattern {
     }
 
     pub fn reload_sounds(&mut self) -> Pattern {
-        let mut newp = self.clone();
+        // let mut newp = self.clone();
         for x in 0..self.xsize {
             for y in 0..self.ysize {
                 if let Some(snd) = self.sounds.get_mut(&(x,y)) {
-                    // dbg!(&snd);
-                    snd.reload_data().unwrap();
+                    println!("RELOAD {:?}", &snd.name);
+                    snd.data = snd.reload_data().unwrap().data;
                     // let s = snd.reload_data().unwrap();
                     // snd.data = s.data.clone();
                 }
             }
         }
-        newp.clone()
+        // newp.clone()
+        self.clone()
     }
 
     pub fn save(&self) {

+ 1 - 15
src/main.rs

@@ -31,25 +31,12 @@ fn collect_patterns (root: &str) -> Vec<Pattern> {
     .filter_map(|e| e.ok())
     .filter(|e| e.path().is_file())
     .map(|f| Pattern::load(f.path()))
-    .map(|p| dbg!(p))
+    // .map(|p| dbg!(p))
     .filter_map(|e| e.ok())
     .collect()
 }
 
 
-// fn collect_patterns (root: &str) -> Vec<Pattern> {
-//     let mut pat = vec![];
-    
-//     for f in WalkDir::new(root)
-//     .into_iter()
-//     .filter_map(|e| e.ok())
-//     .filter(|e| e.path().is_file())
-//     {
-//         let x = 
-//     }    
-//     pat
-// }
-
 
 fn main() {
 
@@ -231,7 +218,6 @@ fn main() {
                     }
                     ui.same_line(0.0);
                     if ui.small_button(&im_str!("clr##{}", y) ){
-                        dbg!(&y);
                         active_pattern.clear_sounds(y);
                     }