--- title: "Better Programming!" type: "article" slug: "better-programming-5" url: "http://localhost/article/better-programming-5/" markdown_url: "http://localhost/article/better-programming-5.md" published_at: "2026-01-25T20:29:48+00:00" modified_at: "2026-06-21T23:25:49+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "Last month we thought we were finished with the SOUND EFFECTS but we found a method of creating a simulated two-voice BEEP. So we are telling you how to do this effect that works on both the TS2068 and the SPECTRUM without any modification whatsoever. So here it is: First you need 2 variables to…" category: - name: "Byte Power" slug: "byte-power" taxonomy: "category" url: "http://localhost/category/periodicals/byte-power/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - 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: "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/" issues_articles: - id: 38577 title: "Byte Power Spring 1987" type: "issue" url: "http://localhost/issue/byte-power-7/" pubdate: "Spring 1987" archive_link: true article_media: - id: 63120 title: "Duo-Voice (Beep)" type: "computer_media" url: "http://localhost/computer_media/duo-voice-beep/" - id: 63123 title: "Tri-Voice (Beep)" type: "computer_media" url: "http://localhost/computer_media/tri-voice-beep/" --- # Better Programming! Last month we thought we were finished with the SOUND EFFECTS but we found a method of creating a simulated two-voice BEEP. So we are telling you how to do this effect that works on both the TS2068 and the SPECTRUM without any modification whatsoever. So here it is: First you need 2 variables to hold the addresses of the notes (number of the note in a number array) and 4 variables (2 for each voice) to hold the notes and durations. What we will do is play the two notes at the same time by alternating the note being played. That is we play the first voice for say, 1/100th of a second and then we play the second voice for also 1/100th of a second. This will create the effect of two voices. Let’s see what the program will look like: ``` 6 LET A=0: LET A1=07 LET B=0: LET B1=0 10 LET V1=50000: LET V2=50250 20 GOSUB 100: GOSUB 200 30 LET A1=A1-1: IF A1=0 THEN GOSUB 100 35 LET B1=B1-1: IF B1=0 THEN GOSUB 200 42 IF A=255 THEN STOP 45 IF A>=254 AND B>=254 THEN PAUSE 1: GOTO 30 50 IF A>=254 THEN LET A=B55 IF B>=254 THEN LET B=A 60 BEEP .015,A-36: BEEP .015,B-36 70 GOTO 30 100 IF A=255 THEN RETURN 110 LET A=PEEK V1: LET A1=PEEK (V1+1): LET V1=V1+2 120 RETURN 200 IF B=255 THEN RETURN 210 LET B=PEEK V2: LET B1=PEEK (V2+1): LET V2=V2+2 220 RETURN ``` Line 6-20 will initialise the variables and get the first two notes. Line 30-35 will decrease the counters for the duration of the notes and if a counter is equal to 0 then the computer gets the next note for the appropriate voice. Line 42 checks if music over Line 45 checks if both notes are rests and pauses for 1/60th of a second if so. Line 50 checks if voice 1 is a pause and if so it assigns Variable A with the value of voice 2 so you will hear voice 2 alone Line 55 same as Line 50 but will assign Variable B the value of voice 1 so you will hear voice 1 alone. Line 60 plays the notes. Line 70 completes the loop. Line 100-220 will get the notes for the appropriate voice. See it is pretty easy, isn’t it? You will find this program right after INKEY$ on the cassette. Also you can make a three voice music using this technique, just add the variables and lines you need and accelerate the tempo (BEEP .008 or faster). You will also find TRI-VOICE on the tape, it an example of 3 voice music. Well, NOW it’s the last chapter in the series of the SOUND EFFECTS! See you next month for more tips for the TS2068 and SPECTRUM! ## Source Code: Duo-Voice (Beep) ``` 0 1 REM DUO-VOICE (BEEP) 2 REM RESET 1987 BYTE POWER 3 REM WRITTEN BY K. BOISVERT 4 5 REM INITIALISE VARIABLES 6 LET A=0: LET A1=0: LET B=0: LET B1=0 10 LET V1=50000: LET V2=50250 19 REM GET FIRST NOTES 20 GO SUB 100: GO SUB 200 29 REM COUNTER FOR VOICE 1 IF 0 THEN GET NEXT NOTE 30 LET A1=A1-1: IF A1=0 THEN GO SUB 100 34 REM COUNTER FOR VOICE 2 IF 0 THEN GET NEXT NOTE 35 LET B1=B1-1: IF B1=0 THEN GO SUB 200 41 REM CHECK IF END OF MUSIC YOU MAY NEED TO CHANGE THIS FOR YOUR OWN WAY OF KNOWING WHEN MUSIC IS FINISHED 42 IF A=255 THEN STOP 44 REM CHECK IF BOTH A PAUSE 45 IF A>=254 AND B>=254 THEN PAUSE 1: GO TO 30 49 REM IF ONLY VOICE 1 IS A PAUSE THEN PLAY THE SAME NOTE AS VOICE 2 BUT STILL USING COUNTER FOR VOICE 1 50 IF A>=254 THEN LET A=B 54 REM IF ONLY VOICE 2 IS A PAUSE THEN PLAY THE SAME NOTE AS VOICE 2 BUT STILL USING COUNTER FOR VOICE 2 55 IF B>=254 THEN LET B=A 59 REM PLAY THE NOTES ONE RIGHT AFTER THE OTHER A-36 AND B-36 MEANS MUSIcomp DATA -36 (TO GET THE RIGHT NOTE, SEE SEE MUSIcomp V1.1) IF YOU PUT YOUR OWN DATA YOU WILL NOT NEED TO ALTER THE VALUES OF A OR B. IF YOU WANT AN OCTAVE HIGHER, JUST ADD [-/+] 12 TIMES THE # OF OCTAVES TO BE ADDED OR SUBSTRACTED. IE:IF YOU WANT 3 OCTAVES LOWER, SUBSTRACT 36. 60 BEEP .015,A-36: BEEP .015,B-36 69 REM COMPLETE LOOP 70 GO TO 30 99 REM IF VOICE FINISHED THEN DO NOT GET ANY MORE NOTES 100 IF A=255 THEN RETURN 109 REM GET NEXT NOTE OF VOICE1 110 LET A=PEEK V1: LET A1=PEEK (V1+1): LET V1=V1+2 120 RETURN 199 REM IF VOICE FINISHED THEN DO NOT GET ANY MORE NOTES 200 IF B=255 THEN RETURN 209 REM GET NEXT NOTE OF VOICE2 210 LET B=PEEK V2: LET B1=PEEK (V2+1): LET V2=V2+2 220 RETURN 8999 REM LOADER 9000 LOAD "DUO-MUSIC"CODE 5E4,495: RUN 9998 REM SAVE PROGRAM 9999 SAVE "DUO-VOICE" LINE 9000: SAVE "DUO-MUSIC"CODE 5E4,495 ``` ## Source Code: Tri-Voice (Beep) ``` 0 1 REM TRI-VOICE (BEEP) 2 REM RESET 1987 BYTE POWER 3 REM WRITTEN BY K. BOISVERT 4 5 REM INITIALISE VARIABLES 6 LET A=0: LET A1=0: LET B=0: LET B1=0: LET C=0: LET C1=0 10 LET V1=50000: LET V2=50114: LET V3=50372 19 REM GET FIRST NOTES 20 GO SUB 100: GO SUB 200: GO SUB 300 29 REM COUNTER FOR VOICE 1 IF 0 THEN GET NEXT NOTE 30 LET A1=A1-1: IF A1=0 THEN GO SUB 100 34 REM COUNTER FOR VOICE 2 IF 0 THEN GET NEXT NOTE 35 LET B1=B1-1: IF B1=0 THEN GO SUB 200 39 REM COUNTER FOR VOICE 3 IF 0 THEN GET NEXT NOTE 40 LET C1=C1-1: IF C1=0 THEN GO SUB 300 41 REM CHECK IF END OF MUSIC YOU MAY NEED TO CHANGE THIS FOR YOUR OWN WAY OF KNOWING WHEN MUSIC IS FINISHED 42 IF A=255 THEN STOP 44 REM SPECIAL CHECK SINCE 3 VOICE MUSIC 2 VOICES CAN BE OFF AT THE SAME TIME! 45 IF A>=254 AND B>=254 AND B>=254 THEN PAUSE 1: GO TO 30 46 IF B>=254 AND C>=254 THEN LET C=A: LET B=A 47 IF A>=254 AND B>=254 THEN LET A=C: LET B=C 48 IF C>=254 AND A>=254 THEN LET C=B: LET B=B 49 REM IF ONLY VOICE 1 IS A PAUSE THEN PLAY THE SAME NOTE AS VOICE 2 BUT STILL USING COUNTER FOR VOICE 1 50 IF A>=254 THEN LET A=B 54 REM IF ONLY VOICE 2 IS A PAUSE THEN PLAY THE SAME NOTE AS VOICE 3 BUT STILL USING COUNTER FOR VOICE 2 55 IF B>=254 THEN LET B=C 56 REM IF ONLY VOICE 3 IS A PAUSE THEN PLAY THE SAME NOTE AS VOICE 1 BUT STILL USING COUNTER FOR VOICE 3 57 IF C>=254 THEN LET C=A 59 REM PLAY THE NOTES ONE RIGHT AFTER THE OTHER A-36 AND B-36 MEANS MUSIcomp DATA -36 (TO GET THE RIGHT NOTE, SEE SEE MUSIcomp V1.1) IF YOU PUT YOUR OWN DATA YOU WILL NOT NEED TO ALTER THE VALUES OF A OR B. IF YOU WANT AN OCTAVE HIGHER, JUST ADD [-/+] 12 TIMES THE # OF OCTAVES TO BE ADDED OR SUBSTRACTED. IE:IF YOU WANT 3 OCTAVES LOWER, SUBSTRACT 36. 60 BEEP .014,A-36: BEEP .019,B-36: BEEP .014,C-36 69 REM COMPLETE LOOP 70 GO TO 30 99 REM IF VOICE FINISHED THEN DO NOT GET ANY MORE NOTES 100 IF A=255 THEN RETURN 109 REM GET NEXT NOTE OF VOICE1 110 LET A=PEEK V1: LET A1=PEEK (V1+1): LET V1=V1+2 120 RETURN 199 REM IF VOICE FINISHED THEN DO NOT GET ANY MORE NOTES 200 IF B=255 THEN RETURN 209 REM GET NEXT NOTE OF VOICE2 210 LET B=PEEK V2: LET B1=PEEK (V2+1): LET V2=V2+2 220 RETURN 299 REM IF VOICE FINISHED THEN DO NOT GET ANY MORE NOTES 300 IF C=255 THEN RETURN 309 REM GET NEXT NOTE OF VOICE3 310 LET C=PEEK V3: LET C1=PEEK (V3+1): LET V3=V3+2 320 RETURN 8999 REM LOADER 9000 LOAD "TRI-MUSIC"CODE 5E4,495: RUN 9998 REM SAVE PROGRAM 9999 SAVE "TRI-VOICE" LINE 9000: SAVE "TRI-MUSIC"CODE 5E4,495 ```