Author Topic: Automatic Song Maker  (Read 3499 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Automatic Song Maker
« on: April 30, 2020, 10:12:53 pm »
Hopefully nobody has made this one recently. LOL
I just tossed this together tonight. It doesn't display the notes, but it does countdown the time left.
It randomly generates quick notes through the speakers, like the old fashioned science fiction movies.

Code: QB64: [Select]
  1. start:
  2. PRINT "Automatic Song Maker"
  3. PRINT "By SierraKen"
  4. INPUT "Press Enter to listen to a random song.", a$
  5. amount = INT(RND * 300) + 51
  6. changes = INT(RND * 30) + 10
  7. FOR note = 1 TO amount
  8.     n = INT(RND * 13) + 35
  9.     n2 = INT(RND * changes) + 35
  10.     PLAY "L16N" + STR$(n)
  11.     PLAY "L16N" + STR$(n2)
  12.     am = amount - note
  13.     LOCATE 2, 1: PRINT am
  14.     _DELAY .25
  15. NEXT note
  16. LOCATE 10, 1
  17. PRINT "Again? (Y/N)"
  18. again:
  19. ag$ = INKEY$
  20. IF ag$ = "y" OR ag$ = "Y" THEN GOTO start:
  21. IF ag$ <> "" THEN END
  22. GOTO again:
  23.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Automatic Song Maker
« Reply #1 on: April 30, 2020, 11:37:03 pm »
Hey Ken,

Neat!

I did one for the first prime factor of numbers  2 and up....
Code: QB64: [Select]
  1. ' Audio presentation of numbers.bas for QB64 fork (B+=MGA) 2017-09-20
  2. ' Using Owens 2X Deluxe Mod
  3. _TITLE "Audio Presentation of Numbers as Primes = 0 or First Factor"
  4. COMMON SHARED ff(), topN
  5. topN = 1000000
  6. testlimitN = SQR(topN)
  7. DIM ff(topN + 30)
  8. FOR i = 0 TO topN STEP 30
  9.     ff(i + 2) = 2: ff(i + 3) = 3: ff(i + 4) = 2: ff(i + 5) = 5: ff(i + 6) = 2: ff(i + 8) = 2: ff(i + 9) = 3
  10.     ff(i + 10) = 2: ff(i + 12) = 2: ff(i + 14) = 2: ff(i + 15) = 3: ff(i + 16) = 2: ff(i + 18) = 2
  11.     ff(i + 20) = 2: ff(i + 21) = 3: ff(i + 22) = 2: ff(i + 24) = 2: ff(i + 25) = 5
  12.     ff(i + 26) = 2: ff(i + 27) = 3: ff(i + 28) = 2: ff(i + 30) = 2
  13. ff(2) = 0: ff(3) = 0: ff(5) = 0
  14. pattern(1) = 4: pattern(2) = 2: pattern(3) = 4: pattern(4) = 2
  15. pattern(5) = 4: pattern(6) = 6: pattern(7) = 2: pattern(8) = 6
  16. pcand = 7: patternI = 0
  17. WHILE pcand < testlimitN
  18.     IF ff(pcand) = 0 THEN
  19.         i = pcand * pcand
  20.         patternI2 = patternI
  21.         DO
  22.             IF ff(i) = 0 THEN ff(i) = pcand
  23.             patternI2 = patternI2 + 1
  24.             IF patternI2 = 9 THEN patternI2 = 1
  25.             i = i + pattern(patternI2) * pcand
  26.             IF i > topN THEN EXIT DO
  27.         LOOP
  28.  
  29.     END IF
  30.     patternI = patternI + 1
  31.     IF patternI = 9 THEN patternI = 1
  32.     pcand = pcand + pattern(patternI)
  33. FOR i = 2 TO topN
  34.     CLS
  35.     PRINT i, ff(i)
  36.     IF ff(i) = 0 THEN SOUND 137, 2 ELSE SOUND 137 + (ff(i) MOD 30) * 10, 2 - ff(i) * .001
  37.     _LIMIT 60
  38.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Automatic Song Maker
« Reply #2 on: May 01, 2020, 12:25:51 am »
Thanks B+! That's a really awesome one you got!