--- title: "Better Programming!" type: "article" slug: "better-programming-6" url: "http://localhost/article/better-programming-6/" markdown_url: "http://localhost/article/better-programming-6.md" published_at: "2026-01-25T21:04:42+00:00" modified_at: "2026-06-21T23:23:54+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "First this month we are going to talk about how to get the SOUND when using the SPECTRUM rom on your TS2068. To get the SOUND on the SPECTRUM you would change the SOUND Statement for OUT 245 for the register and OUT 246 for the data. Here is an example: 10 SOUND 8,16;9,16;10,16 You…" category: - name: "Byte Power" slug: "byte-power" taxonomy: "category" url: "http://localhost/category/periodicals/byte-power/" post_tag: - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Eric Boisvert" slug: "boisvert-eric" taxonomy: "indiv" url: "http://localhost/indiv/boisvert-eric/" - name: "Kristian Boisvert" slug: "boisvert-kristian" taxonomy: "indiv" url: "http://localhost/indiv/boisvert-kristian/" publication_r: id: 38570 title: "Byte Power 1st Class Magazine" type: "periodical" url: "http://localhost/periodical/byte-power-1st-class/" authors_r: - name: "Kristian Boisvert" slug: "boisvert-kristian" taxonomy: "indiv" url: "http://localhost/indiv/boisvert-kristian/" - name: "Eric Boisvert" slug: "boisvert-eric" taxonomy: "indiv" url: "http://localhost/indiv/boisvert-eric/" issues_articles: - id: 38576 title: "Byte Power Feb 1987" type: "issue" url: "http://localhost/issue/byte-power-6/" pubdate: "February 1987" archive_link: true article_media: - id: 63191 title: "Out Music" type: "computer_media" url: "http://localhost/computer_media/out-music/" - id: 63192 title: "Envelope Example" type: "computer_media" url: "http://localhost/computer_media/envelope-example/" - id: 63193 title: "2 Voice Beep Example" type: "computer_media" url: "http://localhost/computer_media/2-voice-beep-example/" --- # Better Programming! First this month we are going to talk about how to get the SOUND when using the SPECTRUM rom on your TS2068. To get the SOUND on the SPECTRUM you would change the SOUND Statement for OUT 245 for the register and OUT 246 for the data. Here is an example: ``` 10 SOUND 8,16;9,16;10,16 ``` You would change this line so it would look like this: ``` 10 OUT 245,8: OUT 246,16: OUT 245,9: OUT 246,16: OUT 245,10: OUT 246,16 ``` See, it’s simple! All you do is change the register for OUT 245,(register) and the data for OUT 246,(data)! There is only one little thing when using this method, the tempo will slow down since the computer has more commands to read. To avoid this just change the tempo for a faster one! By the way this tip was sent by JAMES KERR of Dolton, Illinois. Thanks James! The next thing we are going to talk about is how to make your own envelope without using the Envelope Generator. This one is pretty simple too, what you do is play with the music amplitude registers (8-10), lowering and raising the volume to create an envelope. Let’s say you wanted the notes in a music to fade away once they’re played, well you just have to have a FOR-NEXT routine that would lower the volume right after the note has been played. Here is an example: ``` 10 FOR Z=1 TO 18 15 READ A,B,C 20 SOUND 8,15;7,62;0,A;1,B;: PAUSE C*8 30 FOR F=14 TO 5 STEP -1 40 SOUND 8,F 50 NEXT F 60 NEXT Z 70 DATA …,… ``` I will explain line 30 to 50: Line 30 will initialise F, it starts at 14 since the first value of the register 8 was 15 then it will decrement by 1 until 5. That will create the effect. Line 40 will change the register 8 with the value of F. Line 50 will complete the loop. You can make your own envelopes using this technique. The best results obtained by this technique are in machine language since it is much faster you can create better envelopes. Anyways I’m done for this one so let’s move on for the Finale in this series of the SOUND EFFECTS with the TWO VOICE BEEP! To create an illusion of a two voice BEEP you need a machine language routine since BASIC is too slow to handle such a task. First let’s explain the theory: A sound is represented by vibrations or pulses such as 0010100101 (1 sound on, 0 sound off). Let’s say we have:VOICE 1: 0000100001VOICE 2: 0101010101SOUND generated when the two are mixed (voice 1 + voice 2): 0101110101, this would give the illusion of a two voice BEEP! Based on this principle, we created a program that will simulate a two voice BEEP. That program is in fact only two counters (voice 1 & 2). These counters hold the pitch for each notes. Say we have voice 1 = 255 and voice 2 = 200. What the program would do is make a noise (pulse) each time one of the two counters is equal to 0 (zero) and then resets it to the original value (pitch). So every 200 and 255 times the computer would make a noise (pulse) and that would create the illusion of two voices. This program is included right after this magazine (so are two examples of the previous techniques). We did not have time to find the notes so we just made a sine wave sound effect. We will leave it to you to find the right notes! See you next month!!! ## Source Code: Out Music ``` 0 REM OUT MUSIC ©1986 BYTE POWER WRITTEN BY K. BOISVERT 10 FOR z=1 TO 18: READ a,b,c 20 OUT 245,7: OUT 246,60: OUT 245,8: OUT 246,15: OUT 245,9: OUT 246,15: OUT 245,0: OUT 246,a: OUT 245,1: OUT 246,b: OUT 245,2: OUT 246,a+2: OUT 245,3: OUT 246,b 30 PAUSE 9*c: OUT 245,8: OUT 246,0: OUT 245,9: OUT 246,0: NEXT z: STOP 40 DATA 92,4,2,209,5,2,92,4,2,209,5,2,92,4,1,158,4,1,47,5,1,158,4,1,92,4,4,226,3,2,209,5,2,226,3,2,209,5,2,226,3,1,209,5,1,47,5,1,209,5,1,92,4,4 ``` ## Source Code: Envelope Example ``` 0 REM SIMULATED ENVELOPE ©1986 BYTE POWER WRITTEN BY K. BOISVERT 10 FOR z=1 TO 18: READ a,b,c 20 SOUND 7,60;8,15;9,15;0,a;1,b;2,a+2;3,b 30 PAUSE 5*c: FOR f=14 TO 0 STEP -(5-c): SOUND 8,f;9,f: PAUSE 1: NEXT f: NEXT z 40 DATA 92,4,2,209,5,2,92,4,2,209,5,2,92,4,1,158,4,1,47,5,1,158,4,1,92,4,4,226,3,2,209,5,2,226,3,2,209,5,2,226,3,1,209,5,1,47,5,1,209,5,1,92,4,4 ``` ## Source Code: 2 Voice Beep Example ``` 0 REM Two Voice Beep Written By E Boisvert ©1987 BYTE POWER 2 REM MC RELOCATABLE 3 REM (ADDR OF MC)+2=DURATION (1-65535) 4 REM 23728/9 Pitch Voice 1&2 5 REM PITCH (2 TO 255) 6 REM ADDR+21,BORDER COLOR+8 7 REM ADDR+27,BORDER COLOR+24 10 100 GO SUB 300: PRINT AT 10,0;"SINE WAVE SOUND": FOR z=1 TO 4: FOR x=-250 TO 250 STEP 8: POKE 23728,ABS x: POKE 23729,ABS (x+4): POKE 50002,255: POKE 50003,0: RANDOMIZE USR 5e4: NEXT x: NEXT z 200 GO SUB 300: PRINT AT 10,0;"PLAIN 2 VOICE BEEP": FOR z=1 TO 4: FOR x=1 TO 4: POKE 50002,0: POKE 50003,10: POKE 23728,x*4: POKE 23729,x*5: RANDOMIZE USR 5e4: NEXT x: NEXT z 250 GO TO 100 300 CLS : PRINT #1;AT 0,0;"©1987 BYTE POWER By E Boisvert": RETURN 9000 LOAD ""CODE 5e4: RUN 9999 SAVE "2 BEEP" LINE 9000: SAVE "2. V. BEEP"CODE 5e4,49: VERIFY "": VERIFY ""CODE ```