bucket_brigade avatar bucket_brigade committed f6f4370

Added the ability to store selection to a wavetable slot

Comments (0)

Files changed (2)

libneil/src/libzzub/libzzub.cpp

     // Copy samples from source to target.
     int bytes_per_sample = source_info.get_bytes_per_sample();
     for (int i = 0; i < (end - start) * bytes_per_sample; i++) {
-      target_info.samples[i] = source_info.samples[start + i];
+      target_info.samples[i] = source_info.samples[start * bytes_per_sample + i];
     }
     return 0;
   }

src/neil/waveedit.py

             self.window.invalidate_rect((0, 0, w, h), False)
 
     def update_digest(self, channel=0):
+        if self.level == None:
+            return
         w, h = self.get_client_size()
         self.minbuffer, self.maxbuffer, self.ampbuffer = \
             self.level.get_samples_digest(channel, self.range[0], self.range[1],  w)
 
     def fix_range(self):
         begin,end = self.range
+        if self.level == None:
+            return
         begin = max(min(begin, self.level.get_sample_count() - 1), 0)
         end = max(min(end, self.level.get_sample_count()), begin + 1)
         self.range = [begin, end]
                 for i in self.store_submenu.get_children():
                     self.store_submenu.remove(i)
                 for index, name in enumerate(wave_names_generator()):
-                    self.store_submenu.add_item_no_underline(name, lambda x: index + 1)
+                    self.store_submenu.add_item_no_underline(name, self.on_copy_range, index)
             self.context_menu.popup(self, event)
 
+    def on_copy_range(self, widget, index):
+        player = com.get('neil.core.player')
+        if self.selection == None:
+            message(self, "Select a region of the wave first.")
+            return
+        begin, end = self.selection
+        w = player.get_wave(index)
+        w.set_name("Copy of Selection")
+        self.level.copy_sample_range(begin, end, index)
+        player.flush(None, None)
+        player.history_flush_last()
+
     def on_delete_range(self, widget):
         self.delete_range()
         self.sample_changed()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.