What's new

Help!! First time building a Kontakt instrument! Need help cleaning up script bug

skyscapeparadise

New Member
Hey VI Control,

This is my first post here in this community and I'm really excited to start creating virtual instruments from scratch. As part of my studies as an audio and music student at The Evergreen State College in Olympia, WA, I decided to try and create some virtual instruments based on some of the priceless hardware analog synthesizers we have here. I'm starting with a basic Buchla Music Easel sample set. I'm really proud of how this first attempt sounds.

Screenshot (219).png

I recorded three sound sources for the instrument:
  • The dry signal from the synthesizer
  • The dry signal passed through the Moogerfooger FreqBox
  • The dry signal passed through the Moogerfooger MuRF
My goal is to have a toggle switch on the right-hand side of the interface that allows you to select a pedal, and then a large central knob that crossfades between the dry signal and the signal of the pedal you selected via the toggle switch. Eventually I'd like to add a mono/poly toggle switch and four sliders to control an ADSR envelope as well, but first I need to get the core functionality to work. I designed the UI from scratch with custom graphics for everything. So far, the custom graphics I've made (the background, the toggle switch, and the central knob) have mostly worked out. There's an annoying tiny white line that shows up in the middle of the button graphic and I don't know how get rid of it.

My plan for how to make this work was to use simple if statements and variables, and to create a custom modulation envelope in the group editor for each sample group, called FREQBOXMIX and MURFMIX respectively. The one for the dry signal is turned all the way on at default with the "Invert" button selected, and the custom modulation envelopes on the two pedal groups are turned all the way off at default without the "Invert" button selected. I have it set so that when one of the toggles is down, it mutes the other pedal group using the primary envelope for that group (not the custom one).

But right now, the signal doesn't sound right and the knob doesn't do anything so I must have messed up somewhere.

Code:
on init
    make_perfview
    set_ui_height_px(452)
    set_ui_width_px(720)

    set_control_par_str ($INST_WALLPAPER_ID, $CONTROL_PAR_PICTURE, "background")

    declare ui_slider $dial(0, 1000000)
    make_persistent($dial)
    declare $dialId
    $dialId := get_ui_id($dial)

    declare ui_switch $freqbox
    make_persistent($freqbox)
    declare ui_switch $murf

    declare $freqboxId
    $freqboxId := get_ui_id($freqbox)

    declare $murfId
    $murfId := get_ui_id($murf)

    declare $drymix
    $drymix := find_mod(0, "DRYMIX")

    declare $freqboxmix
    $freqboxmix := find_mod(1, "FREQBOXMIX")

    declare $murfmix
    $murfmix := find_mod(2, "MURFMIX")

    declare $freqboxmute
    declare $murfmute

    set_control_par_str($dialId, $CONTROL_PAR_PICTURE, "dial")
    set_control_par($dialId, $CONTROL_PAR_POS_X, 280)
    set_control_par($dialId, $CONTROL_PAR_POS_Y, 79)
    set_control_par($dialId, $CONTROL_PAR_MOUSE_BEHAVIOUR, -750)

    set_control_par_str($freqboxId, $CONTROL_PAR_PICTURE, "button")
    set_control_par($freqboxId, $CONTROL_PAR_POS_X, 514)
    set_control_par($freqboxId, $CONTROL_PAR_POS_Y, 224)

    set_control_par_str($murfId, $CONTROL_PAR_PICTURE, "button")
    set_control_par($murfId, $CONTROL_PAR_POS_X, 514)
    set_control_par($murfId, $CONTROL_PAR_POS_Y, 250)

    $freqbox := 1
    $murf := 0

    $freqboxmute := get_engine_par($ENGINE_PAR_VOLUME, 1, -1, -1)
    $murfmute := get_engine_par($ENGINE_PAR_VOLUME, 2, -1, -1)

end on

on ui_control($freqbox)
    if ($freqbox=1)
    $murf := 0
    set_engine_par($ENGINE_PAR_VOLUME, $freqboxmute, 1, -1, -1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)
    end if

    if ($freqbox=0)
    $murf := 1
    set_engine_par($ENGINE_PAR_VOLUME, $murfmute, 2, -1, -1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)
    end if
end on

on ui_control($murf)
    if ($murf=1)
    $freqbox := 0
    set_engine_par($ENGINE_PAR_VOLUME, $murfmute, 2, -1, -1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)
    end if

    if ($murf=0)
    $freqbox := 1
    set_engine_par($ENGINE_PAR_VOLUME, $freqboxmute, 1, -1, -1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)
    end if
end on

on ui_control($dial)
  set_engine_par($drymix, $dial, 0, 1, 0)
    set_engine_par($freqboxmix, $dial, 1, 1, 0)
    set_engine_par($murfmix, $dial, 2, 1, 0)

end on

Any insight into what might be wrong would be appreciated a lot! Once I have the code for this project down, I'm planning on creating instruments from a ton of the synthesizers here and submitting them to Christian Henson's Pianobook project for anyone in the world to download for free. Thank you so much for any help you can provide to my efforts.

Kady
 
I think you're needlessly overcomplicating this. You have a dry:wet mix knob and a switch to select to which pedal signal to mix to. This can be done in a much simpler way, without any modulation, just by using group volumes. But first you need to have a lookup array to do a proper equal power dry:wet mix...

Code:
on init
    declare %ep_vol[1001] := (0, 0, 0, 0, 29240, 29240, 29240, 29240, 36840, 36840, 42172, 42172, 46416, 46416, 50000, 53133, 55934, 55934, 58480, 60822, 62996, 65030, 66943, 68753, 70473, 73681, 75185, 76631, 79370, 80671, 81932, 84343, 86624, 87721, 89835, 90856, 92832, 94727, 96549, 98305, 100000, 101640, 103228, 104769, 106266, 107722, 109139, 111199, 112531, 113832, 115729, 116961, 118760, 119931, 121644, 123311, 124397, 125992, 127548, 129066, 130550, 132001, 133420, 134810, 136172, 137507, 138817, 140525, 141780, 143013, 144625, 145810, 147361, 148504, 150000, 151103, 152549, 153968, 155362, 156391, 157742, 159070, 160377, 161662, 162928, 164174, 165706, 166911, 168099, 169270, 170712, 171848, 173248, 174351, 175711, 176784, 178108, 179412, 180441, 181712, 182965, 184201, 185422, 186626, 187814, 188988, 190148, 191293, 192425, 193766, 194869, 195961, 197254, 198319, 199582, 200623, 201858, 202875, 204083, 205276, 206260, 207429, 208585, 209727, 210858, 211977, 213084, 214179, 215264, 216337, 217577, 218628, 219669, 220700, 221891, 222902, 224070, 225062, 226208, 227180, 228305, 229419, 230522, 231459, 232543, 233616, 234680, 235735, 236780, 237816, 238843, 239861, 241014, 242014, 243006, 243990, 245105, 246072, 247168, 248119, 249197, 250133, 251194, 252246, 253160, 254196, 255223, 256243, 257254, 258258, 259129, 260241, 261222, 262195, 263162, 264121, 265073, 266136, 267074, 268005, 269046, 269963, 270989, 271893, 272904, 273796, 274793, 275673, 276657, 277633, 278603, 279566, 280522, 281367, 282415, 283249, 284284, 285209, 286128, 287041, 287948, 288850, 289845, 290735, 291620, 292597, 293470, 294434, 295297, 296250, 297196, 298043, 298978, 299907, 300739, 301658, 302570, 303478, 304380, 305277, 306169, 307055, 307936, 308813, 309684, 310551, 311498, 312355, 313206, 314054, 314980, 315818, 316651, 317563, 318387, 319289, 320185, 320996, 321883, 322766, 323564, 324437, 325305, 326169, 327029, 327884, 328657, 329580, 330422, 331259, 332093, 332922, 333747, 334568, 335384, 336271, 337080, 337885, 338758, 339555, 340420, 341210, 342066, 342848, 343697, 344471, 345312, 346079, 346912, 347741, 348566, 349318, 350136, 350950, 351760, 352566, 353369, 354168, 354963, 355755, 356543, 357329, 358110, 358953, 359727, 360498, 361266, 362094, 362855, 363613, 364431, 365182, 365993, 366738, 367542, 368280, 369077, 369810, 370600, 371387, 372111, 372892, 373669, 374444, 375156, 375924, 376689, 377451, 378209, 378965, 379718, 380468, 381215, 381959, 382700, 383438, 384174, 384906, 385692, 386419, 387143, 387865, 388639, 389355, 390068, 390833, 391541, 392301, 393003, 393703, 394455, 395203, 395896, 396639, 397326, 398063, 398798, 399479, 400208, 400935, 401660, 402330, 403049, 403767, 404481, 405193, 405902, 406558, 407263, 407965, 408665, 409362, 410057, 410750, 411440, 412178, 412863, 413546, 414227, 414906, 415583, 416306, 416978, 417648, 418315, 419028, 419692, 420353, 421059, 421716, 422371, 423071, 423722, 424417, 425063, 425754, 426397, 427083, 427722, 428404, 429084, 429717, 430393, 431066, 431693, 432363, 433031, 433652, 434316, 434977, 435637, 436251, 436907, 437560, 438212, 438862, 439510, 440114, 440758, 441400, 442041, 442680, 443317, 443952, 444585, 445217, 445847, 446475, 447101, 447725, 448348, 448969, 449629, 450247, 450862, 451477, 452089, 452700, 453309, 453916, 454563, 455167, 455769, 456370, 457009, 457607, 458203, 458838, 459431, 460022, 460651, 461239, 461826, 462451, 463034, 463617, 464236, 464815, 465432, 466008, 466583, 467195, 467767, 468375, 468944, 469550, 470116, 470719, 471282, 471882, 472442, 473039, 473597, 474191, 474746, 475337, 475889, 476477, 477027, 477613, 478160, 478742, 479323, 479867, 480445, 481022, 481562, 482136, 482673, 483245, 483815, 484348, 484916, 485482, 486012, 486576, 487139, 487665, 488225, 488749, 489306, 489862, 490417, 490937, 491489, 492040, 492556, 493105, 493653, 494165, 494711, 495255, 495798, 496306, 496847, 497386, 497891, 498428, 498965, 499466, 500000, 500533, 501031, 501562, 502091, 502587, 503114, 503640, 504132, 504656, 505179, 505701, 506190, 506710, 507228, 507714, 508230, 508746, 509229, 509742, 510255, 510766, 511245, 511755, 512232, 512739, 513246, 513720, 514225, 514728, 515200, 515702, 516203, 516671, 517170, 517637, 518134, 518631, 519095, 519589, 520083, 520544, 521036, 521496, 521986, 522444, 522932, 523389, 523875, 524330, 524815, 525268, 525751, 526203, 526684, 527134, 527614, 528062, 528540, 528987, 529463, 529908, 530353, 530827, 531270, 531742, 532184, 532625, 533094, 533534, 533973, 534440, 534877, 535314, 535779, 536214, 536648, 537111, 537544, 537976, 538407, 538867, 539297, 539727, 540155, 540583, 541011, 541438, 541864, 542317, 542742, 543166, 543589, 544012, 544434, 544856, 545276, 545696, 546116, 546535, 546953, 547370, 547787, 548203, 548591, 549006, 549421, 549835, 550248, 550660, 551045, 551456, 551867, 552277, 552659, 553068, 553477, 553857, 554264, 554671, 555050, 555455, 555860, 556237, 556641, 557018, 557420, 557795, 558197, 558571, 558971, 559344, 559717, 560116, 560488, 560859, 561256, 561626, 561996, 562365, 562759, 563128, 563495, 563863, 564229, 564595, 564987, 565353, 565717, 566082, 566445, 566809, 567172, 567534, 567870, 568232, 568593, 568954, 569314, 569673, 570007, 570366, 570724, 571082, 571414, 571771, 572128, 572459, 572815, 573145, 573499, 573854, 574183, 574511, 574864, 575192, 575544, 575871, 576198, 576549, 576875, 577200, 577525, 577875, 578199, 578523, 578846, 579169, 579492, 579815, 580137, 580459, 580780, 581101, 581421, 581742, 582062, 582357, 582676, 582995, 583313, 583607, 583925, 584243, 584535, 584852, 585144, 585461, 585752, 586068, 586359, 586674, 586964, 587254, 587568, 587858, 588147, 588436, 588749, 589037, 589325, 589613, 589900, 590188, 590474, 590761, 591048, 591334, 591620, 591905, 592167, 592452, 592737, 593021, 593282, 593565, 593826, 594109, 594369, 594652, 594911, 595193, 595452, 595734, 595992, 596250, 596531, 596788, 597046, 597303, 597559, 597816, 598072, 598329, 598608, 598840, 599096, 599351, 599606, 599861, 600116, 600347, 600601, 600855, 601086, 601340, 601593, 601823, 602076, 602306, 602536, 602788, 603017, 603246, 603475, 603727, 603955, 604184, 604412, 604640, 604868, 605095, 605323, 605550, 605778, 606004, 606231, 606435, 606662, 606888, 607092, 607318, 607544, 607747, 607972, 608175, 608400, 608603, 608805, 609030, 609232, 609434, 609636, 609838, 610039, 610263, 610442, 610666, 610844, 611045, 611246, 611447, 611647, 611848, 612026, 612226, 612404, 612604, 612781, 612981, 613158, 613358, 613535, 613712, 613911, 614088, 614265, 614441, 614618, 614794, 614993, 615147, 615323, 615499, 615675, 615851, 616026, 616180, 616356, 616531, 616685, 616860, 617013, 617188, 617341, 617516, 617669, 617822, 617975, 618149, 618302, 618454, 618607, 618759, 618912, 619064, 619216, 619368, 619498, 619650, 619802, 619954, 620084, 620236, 620366, 620517, 620647, 620798, 620928, 621058, 621187, 621339, 621468, 621597, 621727, 621856, 621985, 622115, 622244, 622373, 622502, 622610, 622738, 622867, 622975, 623104, 623211, 623340, 623447, 623575, 623683, 623790, 623918, 624025, 624132, 624239, 624346, 624453, 624560, 624666, 624773, 624880, 624987, 625072, 625179, 625285, 625370, 625477, 625562, 625668, 625754, 625860, 625945, 626030, 626115, 626222, 626307, 626392, 626476, 626561, 626646, 626731, 626795, 626880, 626965, 627049, 627113, 627198, 627261, 627346, 627409, 627494, 627558, 627621, 627706, 627769, 627832, 627896, 627959, 628023, 628086, 628149, 628213, 628276, 628339, 628382, 628445, 628508, 628550, 628614, 628656, 628719, 628761, 628803, 628867, 628909, 628951, 628993, 629035, 629077, 629119, 629162, 629204, 629246, 629288, 629330, 629351, 629393, 629414, 629456, 629498, 629519, 629540, 629582, 629603, 629624, 629666, 629687, 629708, 629729, 629750, 629771, 629792, 629814, 629814, 629834, 629856, 629876, 629876, 629897, 629897, 629919, 629919, 629940, 629940, 629940, 629940, 629961, 629961, 629961, 629961)

    declare ui_switch $Freqbox
    declare ui_switch $Murf
    declare ui_slider $PedalMix (0, 1000)

    $Freqbox := 1

    make_persistent($Freqbox)
    make_persistent($Murf)
    make_persistent($PedalMix)
end on

function Mix()
    set_engine_par($ENGINE_PAR_VOLUME, %ep_vol[1000 - $PedalMix], 0, -1, -1)
    set_engine_par($ENGINE_PAR_VOLUME, %ep_vol[$PedalMix] * $Freqbox, 1, -1, -1)
    set_engine_par($ENGINE_PAR_VOLUME, %ep_vol[$PedalMix] * $Murf, 2, -1, -1)
end function

on ui_control ($Freqbox)
    $Murf := 1 - $Freqbox
    call Mix()
end on

on ui_control ($Murf )
    $Freqbox:= 1 - $Murf
    call Mix()
end on

on ui_control ($PedalMix)
    call Mix()
end on


That should do it, I think.


There's an annoying tiny white line that shows up in the middle of the button graphic and I don't know how get rid of it.

That's the text on the button. Just do set_text($buttonname, "") to clear it.
 
Thank you so much!! This is so much cleaner than what I was trying to do before and it works beautifully. Couldn't have figured this out without your help. 🙂
 
Top Bottom