-d -m1 -W -3 -o threnody.wav sr=48000 ksmps=1 nchnls=4 0dbfs=1 ; sine wave gi_sine = ftgen(1, 0, 2^18, 10, 1) #define EDO_SIZE #600# #define EDO_MULT #3# #define E(Idx) #2^($Idx/$EDO_SIZE)# gi600 = ftgen(100, 0, $EDO_SIZE * $EDO_MULT, -51, $EDO_SIZE, 2, 480, 48, 1, $E(1), $E(2), $E(3), $E(4), $E(5), $E(6), $E(7), $E(8), $E(9), $E(10), $E(11), $E(12), $E(13), $E(14), $E(15), $E(16), $E(17), $E(18), $E(19), $E(20), $E(21), $E(22), $E(23), $E(24), $E(25), $E(26), $E(27), $E(28), $E(29), $E(30), $E(31), $E(32), $E(33), $E(34), $E(35), $E(36), $E(37), $E(38), $E(39), $E(40), $E(41), $E(42), $E(43), $E(44), $E(45), $E(46), $E(47), $E(48), $E(49), $E(50), $E(51), $E(52), $E(53), $E(54), $E(55), $E(56), $E(57), $E(58), $E(59), $E(60), $E(61), $E(62), $E(63), $E(64), $E(65), $E(66), $E(67), $E(68), $E(69), $E(70), $E(71), $E(72), $E(73), $E(74), $E(75), $E(76), $E(77), $E(78), $E(79), $E(80), $E(81), $E(82), $E(83), $E(84), $E(85), $E(86), $E(87), $E(88), $E(89), $E(90), $E(91), $E(92), $E(93), $E(94), $E(95), $E(96), $E(97), $E(98), $E(99), $E(100), $E(101), $E(102), $E(103), $E(104), $E(105), $E(106), $E(107), $E(108), $E(109), $E(110), $E(111), $E(112), $E(113), $E(114), $E(115), $E(116), $E(117), $E(118), $E(119), $E(120), $E(121), $E(122), $E(123), $E(124), $E(125), $E(126), $E(127), $E(128), $E(129), $E(130), $E(131), $E(132), $E(133), $E(134), $E(135), $E(136), $E(137), $E(138), $E(139), $E(140), $E(141), $E(142), $E(143), $E(144), $E(145), $E(146), $E(147), $E(148), $E(149), $E(150), $E(151), $E(152), $E(153), $E(154), $E(155), $E(156), $E(157), $E(158), $E(159), $E(160), $E(161), $E(162), $E(163), $E(164), $E(165), $E(166), $E(167), $E(168), $E(169), $E(170), $E(171), $E(172), $E(173), $E(174), $E(175), $E(176), $E(177), $E(178), $E(179), $E(180), $E(181), $E(182), $E(183), $E(184), $E(185), $E(186), $E(187), $E(188), $E(189), $E(190), $E(191), $E(192), $E(193), $E(194), $E(195), $E(196), $E(197), $E(198), $E(199), $E(200), $E(201), $E(202), $E(203), $E(204), $E(205), $E(206), $E(207), $E(208), $E(209), $E(210), $E(211), $E(212), $E(213), $E(214), $E(215), $E(216), $E(217), $E(218), $E(219), $E(220), $E(221), $E(222), $E(223), $E(224), $E(225), $E(226), $E(227), $E(228), $E(229), $E(230), $E(231), $E(232), $E(233), $E(234), $E(235), $E(236), $E(237), $E(238), $E(239), $E(240), $E(241), $E(242), $E(243), $E(244), $E(245), $E(246), $E(247), $E(248), $E(249), $E(250), $E(251), $E(252), $E(253), $E(254), $E(255), $E(256), $E(257), $E(258), $E(259), $E(260), $E(261), $E(262), $E(263), $E(264), $E(265), $E(266), $E(267), $E(268), $E(269), $E(270), $E(271), $E(272), $E(273), $E(274), $E(275), $E(276), $E(277), $E(278), $E(279), $E(280), $E(281), $E(282), $E(283), $E(284), $E(285), $E(286), $E(287), $E(288), $E(289), $E(290), $E(291), $E(292), $E(293), $E(294), $E(295), $E(296), $E(297), $E(298), $E(299), $E(300), $E(301), $E(302), $E(303), $E(304), $E(305), $E(306), $E(307), $E(308), $E(309), $E(310), $E(311), $E(312), $E(313), $E(314), $E(315), $E(316), $E(317), $E(318), $E(319), $E(320), $E(321), $E(322), $E(323), $E(324), $E(325), $E(326), $E(327), $E(328), $E(329), $E(330), $E(331), $E(332), $E(333), $E(334), $E(335), $E(336), $E(337), $E(338), $E(339), $E(340), $E(341), $E(342), $E(343), $E(344), $E(345), $E(346), $E(347), $E(348), $E(349), $E(350), $E(351), $E(352), $E(353), $E(354), $E(355), $E(356), $E(357), $E(358), $E(359), $E(360), $E(361), $E(362), $E(363), $E(364), $E(365), $E(366), $E(367), $E(368), $E(369), $E(370), $E(371), $E(372), $E(373), $E(374), $E(375), $E(376), $E(377), $E(378), $E(379), $E(380), $E(381), $E(382), $E(383), $E(384), $E(385), $E(386), $E(387), $E(388), $E(389), $E(390), $E(391), $E(392), $E(393), $E(394), $E(395), $E(396), $E(397), $E(398), $E(399), $E(400), $E(401), $E(402), $E(403), $E(404), $E(405), $E(406), $E(407), $E(408), $E(409), $E(410), $E(411), $E(412), $E(413), $E(414), $E(415), $E(416), $E(417), $E(418), $E(419), $E(420), $E(421), $E(422), $E(423), $E(424), $E(425), $E(426), $E(427), $E(428), $E(429), $E(430), $E(431), $E(432), $E(433), $E(434), $E(435), $E(436), $E(437), $E(438), $E(439), $E(440), $E(441), $E(442), $E(443), $E(444), $E(445), $E(446), $E(447), $E(448), $E(449), $E(450), $E(451), $E(452), $E(453), $E(454), $E(455), $E(456), $E(457), $E(458), $E(459), $E(460), $E(461), $E(462), $E(463), $E(464), $E(465), $E(466), $E(467), $E(468), $E(469), $E(470), $E(471), $E(472), $E(473), $E(474), $E(475), $E(476), $E(477), $E(478), $E(479), $E(480), $E(481), $E(482), $E(483), $E(484), $E(485), $E(486), $E(487), $E(488), $E(489), $E(490), $E(491), $E(492), $E(493), $E(494), $E(495), $E(496), $E(497), $E(498), $E(499), $E(500), $E(501), $E(502), $E(503), $E(504), $E(505), $E(506), $E(507), $E(508), $E(509), $E(510), $E(511), $E(512), $E(513), $E(514), $E(515), $E(516), $E(517), $E(518), $E(519), $E(520), $E(521), $E(522), $E(523), $E(524), $E(525), $E(526), $E(527), $E(528), $E(529), $E(530), $E(531), $E(532), $E(533), $E(534), $E(535), $E(536), $E(537), $E(538), $E(539), $E(540), $E(541), $E(542), $E(543), $E(544), $E(545), $E(546), $E(547), $E(548), $E(549), $E(550), $E(551), $E(552), $E(553), $E(554), $E(555), $E(556), $E(557), $E(558), $E(559), $E(560), $E(561), $E(562), $E(563), $E(564), $E(565), $E(566), $E(567), $E(568), $E(569), $E(570), $E(571), $E(572), $E(573), $E(574), $E(575), $E(576), $E(577), $E(578), $E(579), $E(580), $E(581), $E(582), $E(583), $E(584), $E(585), $E(586), $E(587), $E(588), $E(589), $E(590), $E(591), $E(592), $E(593), $E(594), $E(595), $E(596), $E(597), $E(598), $E(599), $E(600), 2.0) gk600[] init $EDO_SIZE * $EDO_MULT copyf2array(gk600, gi600) gkPrimes[] = fillarray(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789) ; mixer channels ga_voices_left init 0 ga_voices_right init 0 ga_bass_left init 0 ga_bass_right init 0 instr Binaural idur = p3 iamp = ampdb(p4) icps = p5 idiff = p6 irise = p7 ifall = p8 ipol = p9 ival = idiff / 2 if (ipol == 0) then ipL = icps-ival ipR = icps+ival else ipL = icps+ival ipR = icps-ival endif aenv = linen(iamp, irise, idur, ifall) aLeft = poscil3(aenv, ipL, gi_sine) aRight = poscil3(aenv, ipR, gi_sine) ga_bass_left += aLeft ga_bass_right += aRight endin instr Voice idur = p3 iamp = p4 ; converted from dB to amp by caller icps = p5 ipan = p6 irise = p7 ifall = p8 kenv = linen(iamp, irise, idur, ifall) asig = vco2(kenv, k(icps), 8) aLeft, aRight pan2 asig, ipan ga_voices_left += aLeft ga_voices_right += aRight endin instr Dispatch idur = p3 iamp = ampdb(p4) iofs = p5 ; offset from end of primes islice = p6 ; size of slice from primes irise = p7 ifall = p8 ; prints("dur=%f amp=%f ofs=%d slice=%d\n", idur, iamp, iofs, islice) seed(0) kcps init 0 kidx init 0 ksegment[] init islice ; ilen = lenarray(gkPrimes) ; iend = (ilen - iofs) - 1 ; istart = iend - islice istart = iofs iend = iofs + islice ksegment[] = slicearray(gkPrimes, istart, iend) ; prints("len=%d end=%d start=%d\n", ilen, iend, istart) while (kidx < islice) do kcps = gk600[ksegment[kidx]] / 2 kpan = random(0, 1) schedulek("Voice", 0, k(idur), k(iamp), kcps, kpan, irise, ifall) kidx += 1 od endin instr Mixer outc(ga_voices_left, ga_voices_right, ga_bass_left, ga_bass_right) ga_voices_left = 0 ga_voices_right = 0 ga_bass_left = 0 ga_bass_right = 0 endin i "Mixer" 0.0 212 i "Binaural" 0.0 205 -23 45 0.7 0.01 0.01 0 i "Binaural" 0.0 205 . 45 0.7 0.01 0.01 1 i "Dispatch" 20.0 105 -30 0 75 7 0.01 i "Dispatch" 50.0 105 . 55 75 7 0.01 i "Dispatch" 70.0 90 . 110 75 7 0.01 i "Dispatch" 85.0 105 . 165 65 7 0.01 i "Dispatch" 100.0 105 . 220 55 7 0.01 e