Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 78de6c9538
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 315 lines (277 sloc) 11.493 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
XiiLangGUI {

var win, projectname, key;
var ixilogo, keyboard, keystring, midivalstring;
var projectview, projectpath, projectsList;
var filenames, synthdesclib, synthdefnames, project;
var recorder, thisversion;

*new { arg projectnamearg;
^super.new.initGUIXii(projectnamearg);
}

initGUIXii { arg projectnamearg;
var mappingwinfunc;
thisversion = 3;
this.addixiMenu;

projectsList = "ixilang/*".pathMatch.collect({arg n; n.basename});
projectname = projectnamearg ? projectsList[0];
projectpath = "ixilang/"++projectname;
filenames = (projectpath++"/samples/*").pathMatch;
filenames = filenames.collect({arg file; file.basename});
filenames = filenames.reject({ |file| file.splitext[1] == "scd" }); // not including the keymapping files
filenames = filenames.reject({ |file| file.splitext[1] == "ixi" }); // not including the keymapping files
filenames = filenames.collect({arg file; file.splitext[0]});

key = "C";

ixilogo = [ // the ixi logo
Point(1,7), Point(8, 1), Point(15,1), Point(15,33),Point(24, 23), Point(15,14),
Point(15,1), Point(23,1),Point(34,13), Point(45,1), Point(61,1), Point(66,6),
Point(66,37), Point(59,43), Point(53,43), Point(53,12), Point(44,22), Point(53,33),
Point(53,43), Point(42,43), Point(34,32),Point(24,43), Point(7,43), Point(1,36), Point(1,8)
];

win = Window.new("ixi lang launcher/mapper", Rect(200, 510, 510, 300), resizable:false).front;

StaticText(win, Rect(40, 110, 50, 16)).string_("projects :");

projectview = ListView(win, Rect(40, 135, 120, 100))
.items_(projectsList)
.value_(projectsList.indexOfEqual(projectname))
.action_({arg view;
projectname = projectsList[view.value] ;
projectpath = "ixilang/*".pathMatch[view.value];
projectsList = "ixilang/*".pathMatch.collect({arg n; n.basename});
filenames = (projectpath++"/samples/*").pathMatch;
filenames = filenames.collect({arg file; file.basename});
filenames = filenames.reject({ |file| file.splitext[1] == "scd" }); // not including the keymapping files
filenames = filenames.reject({ |file| file.splitext[1] == "ixi" }); // not including the keymapping files
filenames = filenames.collect({arg file; file.splitext[0]});
});

Button(win, Rect(40, 250, 80, 20))
.states_([["project folder", Color.black, Color.gray]])
.action_({ [\projectpath, projectpath].postln; ("open "++projectpath).unixCmd})
.font_(Font("Helvetica", 11));

Button(win, Rect(124, 250, 36, 20))
.states_([["rec", Color.black, Color.red.alpha_(0.2)], ["stop", Color.black, Color.red.alpha_(0.4)]])
.action_({arg butt;
if(butt.value == 1, {
recorder = XiiLangRecord(Server.default, 0, 2, 'aiff', 'int16');
recorder.start(projectpath++"/recordings/"++projectname++"_"++Date.getDate.stamp.asString++".aif");
}, {
recorder.stop;
});
})
.font_(Font("Helvetica", 11));

keyboard = MIDIKeyboard(win, Rect(190, 135, 280, 60), 3, 48)
.keyDownAction_({arg note;
key = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"][note%12];
"Key (tonic) : ".post; note.postln;
keyboard.clear;
keyboard.setColor(note, Color.green.alpha_(0.3));
keystring.string_( ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"].wrapAt(note));
midivalstring.string_(note.asString);
}).setColor(60, Color.green.alpha_(0.3));

StaticText(win, Rect(190, 210, 50, 16)).string_("key:");
keystring = StaticText(win, Rect(220, 210, 50, 16)).string_("C");
StaticText(win, Rect(250, 210, 60, 16)).string_("midivalue:");
midivalstring = StaticText(win, Rect(320, 210, 50, 16)).string_(60);

StaticText(win, Rect(190, 10, 350, 120))
.string_("Create a folder within the ixilang folder. The name you give \nthat folder becomes the project's name. In there, create a \nsamples folder in which you place some short samples. \nMap the keys on your keyboard to the sample names.\n\nIf you just want to test, without creating a mapping for a new \nproject, click the 'start' button. Have fun!")
.font_(Font("Helvetica", 10));

Button(win, Rect(190, 250, 65, 20))
.states_([["colors", Color.black, Color.gray]])
.action_({ [\projectname, projectname].postln; XiiLangColors.new(projectname) })
.font_(Font("Helvetica", 11));

Button(win, Rect(262, 250, 65, 20))
.states_([["map keys", Color.black, Color.gray]])
.action_({ mappingwinfunc.value })
.font_(Font("Helvetica", 11));

Button(win, Rect(334, 250, 65, 20))
.states_([["help", Color.black, Color.gray]])
.action_({
// XiiLang.openHelpFile // ixi lang does not have the new helpfile format
(XiiLang.filenameSymbol.asString.dirname++"/XiiLang.html").openTextFile;
})
.font_(Font("Helvetica", 11));

Button(win, Rect(406, 250, 65, 20))
.states_([["start", Color.black, Color.green.alpha_(0.2)]])
.action_({
XiiLang.new(projectname, key, true, true);
})
.font_(Font("Helvetica", 11));

win.drawHook = {
GUI.pen.color = Color.new255(255, 102, 0, 160);
GUI.pen.width = 3;
GUI.pen.translate(47,33);
GUI.pen.scale(1.2,1.2);
GUI.pen.moveTo(1@7);
ixilogo.do({arg point;
GUI.pen.lineTo(point+0.5);
});
GUI.pen.stroke;
};

mappingwinfunc = {
var win, column, letters, synthDefDict, dictFound, savebutt;
var ixiLangInstr;

synthdesclib = SynthDescLib(projectname.asSymbol);
("ixilang/"++projectname++"/synthdefs.scd").load;
SynthDescLib.read;
synthdefnames = SynthDescLib.getLib(projectname.asSymbol).synthDescs.keys.asArray;
if(Object.readArchive(projectpath++"/keyMapping.ixi").isNil, {
synthDefDict = IdentityDictionary.new;
dictFound = false;
}, {
synthDefDict = Object.readArchive(projectpath++"/keyMapping.ixi");
dictFound = true;
});

ixiLangInstr = XiiLangInstr.new(projectname);

column = 0;
letters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";
win = Window.new("mapping keyboard keys to samples - project: "+projectname.quote, Rect(710,410, 460, 766), resizable:false).front;
win.onClose_({
ixiLangInstr.freeBuffers;
});
win.view.keyDownAction_({arg view, cha, modifiers, unicode, keycode;
if(letters.includes(cha), {
{fork{
var a;
a = Synth(synthDefDict[cha.asSymbol], [\freq, 60.midicps]);
0.5.wait;
a.release;
}
}.value;
});
letters.do({arg char, i; // thanks julio
if(char == cha, {
win.view.children[((1+i)*5)].focus(true);
});
});
});

StaticText(win, Rect(19, 8, 20, 15)).string_("1");
StaticText(win, Rect(37, 8, 20, 15)).string_("2");
StaticText(win, Rect(240, 8, 20, 15)).string_("1");
StaticText(win, Rect(258, 8, 20, 15)).string_("2");

letters.do({arg char, i; var j, mapname;
if(dictFound.not, {
synthDefDict[char.asSymbol] = filenames.wrapAt(i);
});
column = (i/26).floor*220;
j = i % 26;
StaticText(win, Rect(15+column, ((j+1)*26)+1, 200, 15)).background_(Color.grey.alpha_(0.5));
// sample synthdefs
PopUpMenu(win, Rect(15+column, (j+1)*26, 15, 16))
.items_(filenames)
.action_({arg view;
mapname.string_(filenames[view.value]);
synthDefDict[char.asSymbol] = filenames[view.value];
savebutt.value_(0);
})
.keyDownAction_({arg view, cha, modifiers, unicode, keycode;
switch(keycode)
{123}{ view.valueAction_(view.value-1); savebutt.value_(0); }
{124}{ view.valueAction_(view.value+1); savebutt.value_(0); }
{126}{ view.valueAction_(view.value-1); savebutt.value_(0); }
{125}{ view.valueAction_(view.value+1); savebutt.value_(0); }
{51}{
win.view.children.do({arg vw, i;
if(vw === view, {
if(i>4, {
win.view.children[i-4].focus(true);
})
})
})
}
{36}{ {fork{
var a;
a = Synth(synthDefDict[char.asSymbol], [\freq, 60.midicps]);
0.5.wait;
a.release;
}
}.value;
}
});
// synthesis synthdefs
PopUpMenu(win, Rect(34+column, (j+1)*26, 15, 16))
.items_(synthdefnames)
.action_({arg view;
if(synthdefnames.size!=0, {
mapname.string_(synthdefnames[view.value]);
synthDefDict[char.asSymbol] = synthdefnames[view.value];
savebutt.value_(0);
});
})
.keyDownAction_({arg view, cha, modifiers, unicode, keycode;
if(synthdefnames.size!=0, {
switch(keycode)
{123}{ view.valueAction_(view.value-1); savebutt.value_(0); }
{124}{ view.valueAction_(view.value+1); savebutt.value_(0); }
{126}{ view.valueAction_(view.value-1); savebutt.value_(0); }
{125}{ view.valueAction_(view.value+1); savebutt.value_(0); }
{51}{
win.view.children.do({arg vw, i;
if(vw === view, {
if(i>3, {
win.view.children[i-1].focus(true);
})
})
})
}
{36}{ {{var x; x = Synth(synthDefDict[char.asSymbol], [\freq, 60.midicps]); 0.5.wait; x.release; }.fork}.value };
});
});
StaticText(win, Rect(58+column, (j+1)*26, 70, 16))
.string_(char++" ->")
.font_(Font("Monaco", 11));
mapname = StaticText(win, Rect(96+column, (j+1)*26, 140, 16))
.string_(
if(dictFound, {
synthDefDict[char.asSymbol];
}, {
filenames.wrapAt(i);
})
)
.font_(Font("Monaco", 11));
});

StaticText(win, Rect(15, 710, 200, 45))
.background_(Color.grey.alpha_(0.5))
.string_(" Use arrow keys, TAB, Delete and \n ENTER to navigate sample library\n 1 = samples, 2 = synths")
.font_(Font("Monaco", 9));

savebutt = Button(win, Rect(235, 710, 200, 20))
.states_([["save mapping file", Color.black, Color.green.alpha_(0.2)], ["saved", Color.black, Color.clear]])
.action_({
synthDefDict.writeArchive(projectpath++"/keyMapping.ixi");
" ---> ixi lang NOTE: You need to restart your session for the new mapping to take function (Press the green 'Start session' button".postln;
})
.font_(Font("Helvetica", 11));
win.view.children[1].focus(true);

}

}

addixiMenu {

var a;
CocoaMenuItem.clearCustomItems;
a = SCMenuGroup(nil, "ixi", 10);

SCMenuItem(a, "Feedback")
.action_({
"open http://www.ixi-audio.net/ixilang/ixilang_feedback.html".unixCmd;
});
SCMenuSeparator(a, 1); // add a separator

SCMenuItem(a, "Survey")
.action_({
"open http://www.ixi-audio.net/ixilang/survey".unixCmd;
});
SCMenuSeparator(a, 3); // add a separator

SCMenuItem(a, "Check for Update")
.action_({
var latestversion, pipe;
// check if user is online: (will return a 4 digit number if not)
a = "curl http://www.ixi-audio.net/ixilang/version.txt".systemCmd;
// then get the version number (from a textfile with only one number in it)
if(a==0, {
pipe = Pipe.new("curl http://www.ixi-audio.net/ixilang/version.txt", "r");
latestversion = pipe.getLine;
pipe.close;
[\latestversion, latestversion, \thisversion, thisversion].postln;
if(latestversion.asFloat > thisversion, {
XiiAlert.new("New version (version "++latestversion++") is available on the ixi website");
{"open http://www.ixi-audio.net".unixCmd}.defer(2.5); // allow for time to read
}, {
XiiAlert.new("You have got the latest version of ixi lang");
});
});
});
}


}

Something went wrong with that request. Please try again.