-
-
Save zeffii/7617869 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ck_wav_write(sublime_plugin.TextCommand): | |
def run(self, edit): | |
# the only requirement is (for now) that a copy of wav_writer.ck be located | |
# in the same folder as the .ck you're trying to record. | |
""" // wav_writer.ck | |
Std.atoi(me.arg(0)) => int num_seconds; | |
me.arg(1) => string wav_name; | |
dac => Gain g => WvOut2 w => blackhole; | |
wav_name + ".wav" => w.wavFilename; | |
1 => w.record; | |
num_seconds::second => now; | |
0 => w.record; | |
""" | |
view = self.view | |
file_path = view.file_name() | |
file_name = os.path.basename(file_path) | |
""" | |
will default to 30 seconds for now, until we set up a dialog. | |
we can use the text editor view as a faux console | |
test if the current line has a section intended as a terminal input | |
we don't need to select, we just need to type | |
// %> 20:new_wavename | |
i append .wav and -s automatically for now. | |
""" | |
selections = view.sel() | |
if selections[0].a == selections[0].b: | |
try: | |
sel = view.line(selections[0]) | |
selection = view.substr(sel) | |
# get the last portion after the comment | |
found_content = selection.rsplit("//", 1)[1] | |
# split and trim. | |
sides = found_content.split("%>") | |
right_side = sides[1].strip() | |
song_duration, wav_name = [s.strip() for s in right_side.split(":")] | |
print('duration:', song_duration, 'new wave name', wav_name) | |
cc = ["wav_writer.ck", str(song_duration), wav_name] | |
chuck_commands = ":".join(cc) | |
except: | |
print(" no spaces between %> , try // %> 20:new_wavename") | |
else: | |
# some convenient detaults | |
wav_name = "temp_test" | |
song_duration = 30 | |
chuck_commands = "wav_writer.ck:30:somename" | |
chuck_init_wav = ["chuck", file_name, chuck_commands, "-s"] | |
print(chuck_init_wav) | |
subprocess.Popen(chuck_init_wav) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment