1 Slider with 2 different (0,1000000) Values

treynterrio
treynterrio Member Posts: 64 Member

is it possible to script a slider with 2 different values?

on init

 declare ui_slider $Slider1(165000*2, 1)

 declare $value

 make_persistent($Slider1)

 declare $k_Slider1

 $k_Slider1 := get_ui_id($Slider1)

 set_control_par_str($k_Slider1, $CONTROL_PAR_PICTURE, „Slider1“)

 set_control_par($k_Slider1, $CONTROL_PAR_POS_X, 512)

 set_control_par($k_Slider1, $CONTROL_PAR_POS_Y, 141)

 set_control_par($k_Slider1, $CONTROL_PAR_MOUSE_BEHAVIOUR, $mouse_resp)

end on


on ui_control($Slider1)

 if ($Slider1 < 165000)

   $value := $Slider1

 else

   $value := 165000 - ($Slider1 - 165000)

 end if

   set_engine_par($ENGINE_PAR_GN_GAIN, 629961 + $value, -1, 2, $NI_MAIN_BUS)

end on

this is my code it goes from (0%) 0 to 6db (50%) and from 6 back to 0 db (100%)

so my question is is it possible to get another different value like (0,1000000) for the same slider?

its for a mix slider between 2 different layers

the main sound lowers the volume from 6db to -init and the effected layer goes from -init to 6db. at 50% the volume of both layers is -12db that's why I needed this code above to push the volume a little bit.

Thanks

Comments

  • noY_T
    noY_T Member Posts: 37 Member

    Yeah theres this array floaing around in ksp subs. It goes from -inf to 0.0db.

    In init:

    declare VOL_MIX[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 pers ui_knob mix(0, 1000, 1)
    

    Then in the conrol callback:

    on ui_control(mix)
        // The group(s) that get more silent when turning mix up
       set_engine_par(ENGINE_PAR_VOLUME, VOL_MIX[1000 - mix], 2, -1, -1)
       // The group(s) that are -inf when mix is all he way to the left and reach 0.0dB all the way to the right
       set_engine_par(ENGINE_PAR_VOLUME, VOL_MIX[mix], 3, -1, -1)
    end on
    
  • treynterrio
    treynterrio Member Posts: 64 Member

    @noY_T when I paste the declare code above in, I get an ERROR: variable expected

  • noY_T
    noY_T Member Posts: 37 Member

    Oh sorry, I used the sublime KSP version.

    on init
     declare %VOL_MIX[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_knob $mix(0,1000,1)
     make_persistent($mix)
    end on
    
    on ui_control($mix)
     set_engine_par($ENGINE_PAR_VOLUME,%VOL_MIX[1000-$mix],2,-1,-1)
     set_engine_par($ENGINE_PAR_VOLUME,%VOL_MIX[$mix],3,-1,-1)
    end on
    
  • treynterrio
    treynterrio Member Posts: 64 Member

    I got it now with the code but instead of a knob I need a slider, this in turn doesn't work.

    declare ui_knob $mix (0,1000,1) musst be a slider when I use this as a slider it jumps straight from -init to 0db.

  • noY_T
    noY_T Member Posts: 37 Member

    You set the slider to (0, 1000)?

Back To Top