Author Topic: Need basic help (pun intended)  (Read 2416 times)

0 Members and 1 Guest are viewing this topic.

Offline thelowerrhythm

  • Newbie
  • Posts: 10
    • View Profile
Need basic help (pun intended)
« on: June 05, 2020, 06:21:16 pm »
Beginner here, messing around with this simple sequencer. I first posted about not being able to get the sound to stop at the end (after key press), and I *sort of* figured that out. However, it only works when the cycle rate (variable R) is high (slow) enough. For example, it works as intended when cycle rate is 8, but not when .1.

Code: QB64: [Select]
  1.  
  2. 1 CLS
  3. COLOR 10, 0
  4. 2 PRINT "±±±±± ²²²²²² °°°°°°"
  5. 3 PRINT "±     ²    ² °"
  6. 4 PRINT "±±±±± ²    ² °°°°°°"
  7. 5 PRINT "    ± ²  ² ²      °"
  8. 6 PRINT "±±±±± ²²²²²² °°°°°°"
  9. COLOR 11, 0
  10. PRINT "8 step waveform generator for toned sequences"
  11. PRINT "or drones at faster speeds (lower cycle)."
  12. PRINT "Input frequencies in Hz from 40 - 16000."
  13. PRINT "Press any key to stop sequence."
  14. COLOR 1, 0
  15. 7 INPUT "FREQ A: ", S1
  16. 8 IF S1 < 40 OR S1 > 16000 THEN GOTO 4
  17. COLOR 2, 0
  18. 10 INPUT "FREQ B: ", S2
  19.  
  20. 11 IF S2 < 40 OR S2 > 16000 THEN GOTO 10
  21. COLOR 3, 0
  22. 16 INPUT "FREQ C: ", S3
  23. 17 IF S3 < 40 OR S3 > 16000 THEN GOTO 16
  24. COLOR 4, 0
  25. 22 INPUT "FREQ D: ", S4
  26. 23 IF S4 < 40 OR S4 > 16000 THEN GOTO 22
  27. COLOR 5, 0
  28. 28 INPUT "FREQ E: ", S5
  29. 29 IF S5 < 40 OR S5 > 16000 THEN GOTO 28
  30. COLOR 6, 0
  31. 32 INPUT "FREQ F: ", S6
  32. 33 IF S6 < 40 OR S6 > 16000 THEN GOTO 32
  33. COLOR 7, 0
  34. 36 INPUT "FREQ G: ", S7
  35. 37 IF S7 < 40 OR S7 > 16000 THEN GOTO 36
  36. COLOR 8, 0
  37. 39 INPUT "FREQ H: ", S8
  38. 41 IF S8 < 40 OR S8 > 16000 THEN GOTO 39
  39. COLOR 9, 0
  40. INPUT "CYCLE RATE(.023+): ", R
  41.     LET k$ = INKEY$
  42.     SOUND S1, R
  43.     COLOR 1, 0
  44.     PRINT "Generating Tone A"
  45.     SOUND S2, R
  46.     COLOR 2, 0
  47.     PRINT "Generating Tone B"
  48.     SOUND S3, R
  49.     COLOR 3, 0
  50.     PRINT "Generating Tone C"
  51.     SOUND S4, R
  52.     COLOR 4, 0
  53.     PRINT "Generating Tone D"
  54.     SOUND S5, R
  55.     COLOR 5, 0
  56.     PRINT "Generating Tone E"
  57.     SOUND S6, R
  58.     COLOR 6, 0
  59.     PRINT "Generating Tone F"
  60.     SOUND S7, R
  61.     COLOR 7, 0
  62.     PRINT "Generating Tone G"
  63.     SOUND S8, R
  64.     COLOR 8, 0
  65.     PRINT "Generating Tone H"
  66.  
  67. LOOP UNTIL k$ <> ""
  68. X = 1
  69. IF X = 1 THEN SOUND 0, 0
  70. INPUT "Enter Q / q to EXIT, anything else to RESTART: ", I$
  71.     CASE "Q"
  72.         GOTO 666
  73.     CASE "q"
  74.         GOTO 666
  75.  
  76. 666 END
  77.  
  78.  
  79.  
  80.  
  81.  
« Last Edit: June 05, 2020, 08:27:24 pm by thelowerrhythm »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Need basic help (pun intended)
« Reply #1 on: June 05, 2020, 08:26:14 pm »
I am no musician or an expert in using QB64, but my first guesses would be... Your DO..LOOP is continuously queuing sound commands and when you press a key, "Hey! Get to the end of the queue."  and when the sounds are finished playing, the loop ends. That's what happened on my machine. As to a solution... I may not be the best choice to ask... No. That's not correct. I 'am not' the best person to ask.

Here is a link to Terry's "simple" piano... (I would hate to see a complicated one... lol) https://www.qb64.org/forum/index.php?topic=2537.msg117793#msg117793

Based on Terry's experience with sound, I would point you in his direction... I apologise for not be able to be of help.
Logic is the beginning of wisdom.

Offline thelowerrhythm

  • Newbie
  • Posts: 10
    • View Profile
Re: Need basic help (pun intended)
« Reply #2 on: June 05, 2020, 08:38:58 pm »
I'm nowhere even near being a novice, so there's that. It's doing what it is supposed to do for you, but it only happens for me at higher cycle rates (=slower sequences). When it's sped up a keypress doesn't end the sound, and when the software restarts its still playing. Not sure why the different cycle speeds would make a difference. Maybe when it's going really fast it isn't pausing to see if its supposed to stop? I don't even know if that makes sense.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Need basic help (pun intended)
« Reply #3 on: June 08, 2020, 02:55:02 am »
Hi thelowerrhythm

please say me
1. why do you like spaghetti code versus modular code?
2. do you try to make a flowchart or mindmap of your code to follow the flow? at a first rapid look it seems that you make a chain of SOUNDs statements so you can stop sound at the end of the chain....
3. if you like use the SOUND keyword, have you seen the difference between QB and QB64? https://www.qb64.org/wiki/index.php/SOUND

Good Coding
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Need basic help (pun intended)
« Reply #4 on: June 08, 2020, 12:43:22 pm »
Hi thelowerrhythm

please say me
1. why do you like spaghetti code versus modular code?
2. do you try to make a flowchart or mindmap of your code to follow the flow? at a first rapid look it seems that you make a chain of SOUNDs statements so you can stop sound at the end of the chain....
3. if you like use the SOUND keyword, have you seen the difference between QB and QB64? https://www.qb64.org/wiki/index.php/SOUND

Good Coding

I thought spaghetti too but he is just checking each input before moving to next, not so bad.

Yeah wiki says sound duration is in units of 1/18 of sec as I understood it. So why .023 as lowest accepted, shouldn't it be 1 as Sound cant do any less?

Could put pauses between sounds to hear what is what.

For all this:
Code: QB64: [Select]
  1. INPUT "Enter Q / q to EXIT, anything else to RESTART: ", I$
  2.     CASE "Q"
  3.         GOTO 666
  4.     CASE "q"
  5.         GOTO 666
  6.  
  7. 666 END
  8.  

2 lines:
Code: QB64: [Select]
  1. INPUT "Enter Q / q to EXIT, anything else to RESTART: ", I$
  2. IF UCASE$(I$) = "Q" THEN END ELSE GOTO 1
  3.  

But then you cant say GOTO 666 (twice!)  ;-))
« Last Edit: June 08, 2020, 12:55:26 pm by bplus »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Need basic help (pun intended)
« Reply #5 on: June 08, 2020, 01:44:00 pm »
Try this:

Maybe you ask: Why SOUND output is different than _SNDRAW? Its, because SOUND create stereo output but SNDRAW contains stereo bug.

Now is possible using sound lenght less than 1.

Code: QB64: [Select]
  1.  
  2. 1 CLS
  3. COLOR 10, 0
  4. 2 PRINT "±±±±± 222222 °°°°°°"
  5. 3 PRINT "±     2    2 °"
  6. 4 PRINT "±±±±± 2    2 °°°°°°"
  7. 5 PRINT "    ± 2  2 2      °"
  8. 6 PRINT "±±±±± 222222 °°°°°°"
  9. COLOR 11, 0
  10. PRINT "8 step waveform generator for toned sequences"
  11. PRINT "or drones at faster speeds (lower cycle)."
  12. PRINT "Input frequencies in Hz from 40 - 16000."
  13. PRINT "Press any key to stop sequence."
  14. COLOR 1, 0
  15. 7 INPUT "FREQ A: ", S1
  16. 8 IF S1 < 40 OR S1 > 16000 THEN GOTO 4
  17. COLOR 2, 0
  18. 10 INPUT "FREQ B: ", S2
  19.  
  20. 11 IF S2 < 40 OR S2 > 16000 THEN GOTO 10
  21. COLOR 3, 0
  22. 16 INPUT "FREQ C: ", S3
  23. 17 IF S3 < 40 OR S3 > 16000 THEN GOTO 16
  24. COLOR 4, 0
  25. 22 INPUT "FREQ D: ", S4
  26. 23 IF S4 < 40 OR S4 > 16000 THEN GOTO 22
  27. COLOR 5, 0
  28. 28 INPUT "FREQ E: ", S5
  29. 29 IF S5 < 40 OR S5 > 16000 THEN GOTO 28
  30. COLOR 6, 0
  31. 32 INPUT "FREQ F: ", S6
  32. 33 IF S6 < 40 OR S6 > 16000 THEN GOTO 32
  33. COLOR 7, 0
  34. 36 INPUT "FREQ G: ", S7
  35. 37 IF S7 < 40 OR S7 > 16000 THEN GOTO 36
  36. COLOR 8, 0
  37. 39 INPUT "FREQ H: ", S8
  38. 41 IF S8 < 40 OR S8 > 16000 THEN GOTO 39
  39. COLOR 9, 0
  40. INPUT "CYCLE RATE(.023+): ", R
  41.     LET k$ = INKEY$
  42.     SOUND2 S1, R
  43.     COLOR 1, 0
  44.     PRINT "Generating Tone A"
  45.     SOUND2 S2, R
  46.     COLOR 2, 0
  47.     PRINT "Generating Tone B"
  48.     SOUND2 S3, R
  49.     COLOR 3, 0
  50.     PRINT "Generating Tone C"
  51.     SOUND2 S4, R
  52.     COLOR 4, 0
  53.     PRINT "Generating Tone D"
  54.     SOUND2 S5, R
  55.     COLOR 5, 0
  56.     PRINT "Generating Tone E"
  57.     SOUND2 S6, R
  58.     COLOR 6, 0
  59.     PRINT "Generating Tone F"
  60.     SOUND2 S7, R
  61.     COLOR 7, 0
  62.     PRINT "Generating Tone G"
  63.     SOUND2 S8, R
  64.     COLOR 8, 0
  65.     PRINT "Generating Tone H"
  66.  
  67. LOOP UNTIL k$ <> ""
  68. X = 1
  69. IF X = 1 THEN SOUND 0, 0
  70. INPUT "Enter Q / q to EXIT, anything else to RESTART: ", I$
  71.     CASE "Q"
  72.         GOTO 666
  73.     CASE "q"
  74.         GOTO 666
  75.  
  76. 666 END
  77.  
  78.  
  79.  
  80.  
  81. SUB SOUND2 (frequency AS INTEGER, lenght AS SINGLE)
  82.     STATIC u
  83.     l = lenght / 18
  84.     samples = _SNDRATE * l
  85.     s = _PI / (_SNDRATE / frequency) * 2
  86.  
  87.     DO UNTIL plsam >= samples
  88.         _SNDRAW SIN(u) * .8, SIN(u) * .8
  89.         u = u + s
  90.         IF ABS(s) >= _SNDRATE / frequency THEN s = s * -1
  91.         plsam = plsam + 1
  92.     LOOP
  93.     DO UNTIL _SNDRAWLEN = 0: LOOP 'comment this row and play in background. BUT, if you call often SNDRAW, is this very memory offensive, therefore is very recomended controlling SNDRAW cache using SNDRAWLEN!
  94.    END SUB
  95.  
« Last Edit: June 08, 2020, 02:30:00 pm by Petr »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Need basic help (pun intended)
« Reply #6 on: June 08, 2020, 05:21:48 pm »
@bplus
Quote
I thought spaghetti too but he is just checking each input before moving to next, not so bad.
yes so I like SOS trough the lines 6-10

1. but also if thelowerrhythm uses finely the GOTO to creates loops that control data input he has put a first error with GOTO 4 that must be converted into GOTO 1  at first control of input data.
Code: QB64: [Select]
  1. 4 PRINT "±±±±± 2    2 °°°°°°"
  2. 5 PRINT "    ± 2  2 2      °"
  3. 6 PRINT "±±±±± 222222 °°°°°°"
  4. COLOR 11, 0
  5. PRINT "8 step waveform generator for toned sequences"
  6. PRINT "or drones at faster speeds (lower cycle)."
  7. PRINT "Input frequencies in Hz from 40 - 16000."
  8. PRINT "Press any key to stop sequence."
  9. COLOR 1, 0
  10. 7 INPUT "FREQ A: ", S1
  11. 8 IF S1 < 40 OR S1 > 16000 THEN GOTO 4

2. But the user cannot stop the cycle of input data... better to use a default value if user mystype the value...
I hate how INPUT going to head of line letting shift to up the screen output
Code: QB64: [Select]
  1. 10 INPUT "FREQ B: ", S2
  2.  IF S2 = 0 then S2 = 40
  3. 11 IF S2 < 40 OR S2 > 16000 THEN GOTO 10

3. the single chain of sounds (sound S1, R....sound R8,R) in the loop  cannot be interrupted!

Code: QB64: [Select]
  1.     LET k$ = INKEY$
  2.     SOUND S1, R
  3.     COLOR 1, 0
  4.     PRINT "Generating Tone A"
  5.     SOUND S2, R
  6.     COLOR 2, 0
  7.     PRINT "Generating Tone B"
  8.     SOUND S3, R
  9.     COLOR 3, 0
  10.     PRINT "Generating Tone C"
  11.     SOUND S4, R
  12.     COLOR 4, 0
  13.     PRINT "Generating Tone D"
  14.     SOUND S5, R
  15.     COLOR 5, 0
  16.     PRINT "Generating Tone E"
  17.     SOUND S6, R
  18.     COLOR 6, 0
  19.     PRINT "Generating Tone F"
  20.     SOUND S7, R
  21.     COLOR 7, 0
  22.     PRINT "Generating Tone G"
  23.     SOUND S8, R
  24.     COLOR 8, 0
  25.     PRINT "Generating Tone H"
  26.  
  27. LOOP UNTIL k$ <> ""
  28.  

4. pressing a key the sound doesn't stop until the buffer of sound becomes void
in my MOD it is possible if  SOUND 0,0 would work fine.
5. all sounds have the same duration of time, so little variation of sound generated

6. what is it?
Code: QB64: [Select]
  1. X = 1
  2. IF X = 1 THEN SOUND 0, 0
it seems this
Code: QB64: [Select]
  1. SOUND 0,0

.... so here my version of this spaghetti program.
Code: QB64: [Select]
  1. DIM S(1 TO 8) AS INTEGER
  2. NameTone$ = "ABCDEFGH"
  3. FOR a = 1 TO 8 STEP 1
  4.    1 CLS
  5.     COLOR 10, 0
  6.    2 PRINT "±±±±± ²²²²²² °°°°°°"
  7.    3 PRINT "±     ²    ² °"
  8.    4 PRINT "±±±±± ²    ² °°°°°°"
  9.    5 PRINT "    ± ²  ² ²      °"
  10.    6 PRINT "±±±±± ²²²²²² °°°°°°"
  11.     COLOR 11, 0
  12.     PRINT ""
  13.     PRINT "8 step waveform generator for toned sequences"
  14.     PRINT "or drones at faster speeds (lower cycle)."
  15.     PRINT ""
  16.     PRINT "Input frequencies in Hz from 40 - 16000."
  17.     PRINT ""
  18.     PRINT "Press any key to stop sequence."
  19.     COLOR a, 0
  20.     PRINT ""
  21.    7 PRINT "FREQ " + MID$(NameTone$, a, 1) + " : ";: INPUT S(a)
  22.     IF S(a) = 0 THEN S(a) = 40 ' user press Enter to use default value
  23.    8 IF S(a) < 40 OR S(a) > 16000 THEN GOTO 1
  24. COLOR 9, 0
  25. INPUT "CYCLE RATE(.023+): ", R
  26. FOR a = 1 TO 8 STEP 1
  27.     LET k$ = INKEY$
  28.     SOUND S(a), R
  29.     COLOR a, 0
  30.     PRINT "Generating Tone " + MID$(NameTone$, a, 1)
  31.     IF a = 8 THEN a = 1 'infinite loop
  32.     IF k$ <> "" THEN EXIT FOR
  33. SOUND 0, 0 ' this statement doesn't work
  34. INPUT "Enter Q / q to EXIT, anything else to RESTART: ", I$
  35. IF LCASE$(I$) = "q" THEN CLEAR: END ELSE GOTO 1
  36.  

Enjoy Coding Basic
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Need basic help (pun intended)
« Reply #7 on: June 08, 2020, 06:58:52 pm »
@TempodiBasic again an admirable amount of detail analysis but some of your changes strike me as odd too. For instance:
Code: QB64: [Select]
  1.    
  2.    IF S(a) = 0 THEN S(a) = 40 ' user press Enter to use default value
  3.   8 IF S(a) < 40 OR S(a) > 16000 THEN GOTO 1
I think it cruel and unusual punishment to redo all inputs if you make a mistake with one.
Oh wait, I confused line 1 in qb64 code and line 1 in GOTO code, you only go back to just after start of loop.
OK bad example, (mostly... ;)
I do like how you made half a dozen plus variables into one array, no, I love that!

OK what about this line:
Code: QB64: [Select]
  1. SOUND 0, 0 ' this statement doesn't work
Why put it in when you know it doesn't work?

Oh well practice makes perfect.

B+ to both of you :)

Oh I just figured out SOS dahhh... cant see the forest for the trees. bplus getting old, no I never ran the dang code! ;-))
« Last Edit: June 08, 2020, 07:53:06 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Need basic help (pun intended)
« Reply #8 on: June 09, 2020, 12:53:45 am »
@Petr  your reply #5 sounds great and looks like drawing keeps going with sound, nice one!
« Last Edit: June 09, 2020, 11:59:03 am by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Need basic help (pun intended)
« Reply #9 on: June 09, 2020, 05:03:45 am »
Hi Bplus
glad to enjoy you.
but do you must think that this is my spaghetti code... not a modular code :-))
all changes are to shrink the number of line not to save RAM or modularity
I thank you for feedback, so with practice I can improve my coding.

@Petr
great new _SOUND function for QB64  with a third parameter optional "_DONTWAIT" while in default it is _WAIT

this is your prototype at my eyes
Code: QB64: [Select]
  1. CONST P_WAIT = -1 , P_DONTWAIT = 0
  2. SUB SOUND2 (frequency AS INTEGER, lenght AS SINGLE, PWait AS INTEGER)
  3.     STATIC u
  4.     l = lenght / 18
  5.     samples = _SNDRATE * l
  6.     s = _PI / (_SNDRATE / frequency) * 2
  7.  
  8.     DO UNTIL plsam >= samples
  9.         _SNDRAW SIN(u) * .8, SIN(u) * .8
  10.         u = u + s
  11.         IF ABS(s) >= _SNDRATE / frequency THEN s = s * -1
  12.         plsam = plsam + 1
  13.     LOOP
  14.  if PWait then   DO UNTIL _SNDRAWLEN = 0: LOOP 'comment this row and play in background. BUT, if you call often SNDRAW, is this very memory offensive, therefore is very recomended controlling SNDRAW cache using SNDRAWLEN!
  15.  

here in the original spaghetti code
Code: QB64: [Select]
  1. CONST P_WAIT = -1, P_DONTWAIT = 0
  2.  
  3. 1 CLS
  4. COLOR 10, 0
  5. 2 PRINT "±±±±± 222222 °°°°°°"
  6. 3 PRINT "±     2    2 °"
  7. 4 PRINT "±±±±± 2    2 °°°°°°"
  8. 5 PRINT "    ± 2  2 2      °"
  9. 6 PRINT "±±±±± 222222 °°°°°°"
  10. COLOR 11, 0
  11. PRINT "8 step waveform generator for toned sequences"
  12. PRINT "or drones at faster speeds (lower cycle)."
  13. PRINT "Input frequencies in Hz from 40 - 16000."
  14. PRINT "Press any key to stop sequence."
  15. COLOR 1, 0
  16. 7 INPUT "FREQ A: ", S1
  17. 8 IF S1 < 40 OR S1 > 16000 THEN GOTO 4
  18. COLOR 2, 0
  19. 10 INPUT "FREQ B: ", S2
  20.  
  21. 11 IF S2 < 40 OR S2 > 16000 THEN GOTO 10
  22. COLOR 3, 0
  23. 16 INPUT "FREQ C: ", S3
  24. 17 IF S3 < 40 OR S3 > 16000 THEN GOTO 16
  25. COLOR 4, 0
  26. 22 INPUT "FREQ D: ", S4
  27. 23 IF S4 < 40 OR S4 > 16000 THEN GOTO 22
  28. COLOR 5, 0
  29. 28 INPUT "FREQ E: ", S5
  30. 29 IF S5 < 40 OR S5 > 16000 THEN GOTO 28
  31. COLOR 6, 0
  32. 32 INPUT "FREQ F: ", S6
  33. 33 IF S6 < 40 OR S6 > 16000 THEN GOTO 32
  34. COLOR 7, 0
  35. 36 INPUT "FREQ G: ", S7
  36. 37 IF S7 < 40 OR S7 > 16000 THEN GOTO 36
  37. COLOR 8, 0
  38. 39 INPUT "FREQ H: ", S8
  39. 41 IF S8 < 40 OR S8 > 16000 THEN GOTO 39
  40. COLOR 9, 0
  41. INPUT "CYCLE RATE(.023+): ", R
  42.     LET k$ = INKEY$
  43.     SOUND2 S1, R, P_DONTWAIT
  44.     COLOR 1, 0
  45.     PRINT "Generating Tone A"
  46.     SOUND2 S2, R, P_WAIT
  47.     COLOR 2, 0
  48.     PRINT "Generating Tone B"
  49.     SOUND2 S3, R, P_DONTWAIT
  50.     COLOR 3, 0
  51.     PRINT "Generating Tone C"
  52.     SOUND2 S4, R, P_WAIT
  53.     COLOR 4, 0
  54.     PRINT "Generating Tone D"
  55.     SOUND2 S5, R, P_DONTWAIT
  56.     COLOR 5, 0
  57.     PRINT "Generating Tone E"
  58.     SOUND2 S6, R, P_WAIT
  59.     COLOR 6, 0
  60.     PRINT "Generating Tone F"
  61.     SOUND2 S7, R, P_DONTWAIT
  62.     COLOR 7, 0
  63.     PRINT "Generating Tone G"
  64.     SOUND2 S8, R, P_WAIT
  65.     COLOR 8, 0
  66.     PRINT "Generating Tone H"
  67.  
  68. LOOP UNTIL k$ <> ""
  69. X = 1
  70. IF X = 1 THEN SOUND 0, 0
  71. INPUT "Enter Q / q to EXIT, anything else to RESTART: ", I$
  72.     CASE "Q"
  73.         GOTO 666
  74.     CASE "q"
  75.         GOTO 666
  76.  
  77. 666 END
  78.  
  79.  
  80.  
  81.  
  82. SUB SOUND2 (frequency AS INTEGER, lenght AS SINGLE, PWait AS INTEGER)
  83.     STATIC u
  84.     l = lenght / 18
  85.     samples = _SNDRATE * l
  86.     s = _PI / (_SNDRATE / frequency) * 2
  87.  
  88.     DO UNTIL plsam >= samples
  89.         _SNDRAW SIN(u) * .8, SIN(u) * .8
  90.         u = u + s
  91.         IF ABS(s) >= _SNDRATE / frequency THEN s = s * -1
  92.         plsam = plsam + 1
  93.     LOOP
  94.     IF PWait THEN DO UNTIL _SNDRAWLEN = 0: LOOP 'comment this row and play in background. BUT, if you call often SNDRAW, is this very memory offensive, therefore is very recomended controlling SNDRAW cache using SNDRAWLEN!
  95.  
« Last Edit: June 09, 2020, 05:15:00 am by TempodiBasic »
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Need basic help (pun intended)
« Reply #10 on: June 09, 2020, 05:12:37 am »
@bplus
nothing is perfect but all is perfectable...

about
Quote
OK what about this line:
Code: QB64: [Select]
SOUND 0, 0 ' this statement doesn't work
Why put it in when you know it doesn't work?

it is just to note that for a major backward compatibility to  QBasic this point can be adjusted....
so I imagine that someone with C/C++ knowledge not so dusted like mine must open the box of SOUND and see what it can do...
Do who gives me a SVITOL https://cdn.manomano.com/sbloccante-spray-svitol-P-7201249-13997303_1.jpg or WD40 https://it.rs-online.com/web/p/lubrificanti/1247168?cm_mmc=IT-PLA-DS3A-_-google-_-PLA_IT_IT_Pulizia_e_manutenzione_Whoop-_-(IT:Whoop!)+Lubrificanti-_-1247168&matchtype=&pla-333453465826&gclid=CjwKCAjw5vz2BRAtEiwAbcVIL5-Z65gZPbkrVjPGJbFI4I-ABihHCHsBkFZcPY5E37rduthnX_jNBBoCDWcQAvD_BwE&gclsrc=aw.dsfor my C/C++?
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Need basic help (pun intended)
« Reply #11 on: June 09, 2020, 12:10:53 pm »
LOL well I know WD40 works great on locks, never knew about C/C++ code.

Since started study of sound in this thread, I tried an app experimenting with spacing sound out, see SOS program here: https://www.qb64.org/forum/index.php?topic=2692.0

As important as frequency and duration is to sound, so is the spacing between SOUNDs, might try making a tool that includes spacing with the 2 given parameters.