Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PLAY musak!
#1
Music 
Well here it is, musak! But this is just one example. If allowed it plays five songs at a time, each song is about a minute long. Press [ESC] key to leave.

Code: (Select All)
'by mnrvovrfc 18-June-2023
'requires QB64 Phoenix Edition v3.8 or later
OPTION _EXPLICIT

REDIM scales(1 TO 1) AS STRING
DIM sequ(1 TO 2, 1 TO 20) AS INTEGER
DIM SHARED thiscale(1 TO 5) AS INTEGER, altscale(1 TO 5) AS INTEGER
DIM AS INTEGER i, lscales, song, si, so, u, basenote, numnote, athird
DIM AS INTEGER down
DIM e$

RANDOMIZE TIMER

RESTORE scaleslist
READ e$
DO UNTIL e$ = "END"
lscales = lscales + 1
IF lscales > 1 THEN
REDIM _PRESERVE scales(1 TO lscales) AS STRING
END IF
scales(lscales) = e$
READ e$
LOOP

PRINT "Now if only we have some animation!"
_TITLE "Press [ESC] to quit, [SPACE] for next song."

FOR song = 1 TO 5
PRINT: PRINT "Song"; song
u = Rand(18, 24) * 2
basenote = u
down = 0
si = Random1(lscales)
DO
so = Random1(lscales)
LOOP WHILE si = so
thiscale(1) = basenote
FOR i = 1 TO 4
basenote = basenote + VAL(MID$(scales(si), i, 1))
if basenote > 84 then down = 12
thiscale(i + 1) = basenote
NEXT
for i = 1 to 5
thiscale(i) = thiscale(i) - down
next
basenote = u
down = 0
altscale(1) = basenote
FOR i = 1 TO 4
basenote = basenote + VAL(MID$(scales(so), i, 1))
if basenote > 84 then down = 12
altscale(i + 1) = basenote
NEXT
for i = 1 to 5
altscale(i) = altscale(i) - down
next

e$ = "MB"
IF Random1(3) = 1 THEN e$ = e$ + "MS" ELSE e$ = e$ + "MN"
e$ = e$ + "T" + _TRIM$(STR$(Rand(9, 16) * 10))
e$ = e$ + "@" + _TRIM$(STR$(Random1(3)))
e$ = e$ + "Q10V50"

numnote = Rand(50, 150) * 4
athird = numnote \ 3
DO
e$ = e$ + "V50"
u = Random1(20)
SELECT CASE u
CASE 1
e$ = e$ + "L32" + en$(2) + en$(5) + en$(2) + en$(5)
numnote = numnote - 4
CASE 2
e$ = e$ + "L32" + en$(1) + en$(5) + en$(2) + en$(5)
numnote = numnote - 4
CASE 3
e$ = e$ + "L32" + en$(5) + en$(5) + "L16" + en$(5)
numnote = numnote - 3
CASE 4
e$ = e$ + "L16" + en$(5) + "L32" + en$(5) + en$(5)
numnote = numnote - 3
CASE 5
e$ = e$ + "L16" + en$(5) + en$(5)
numnote = numnote - 2
CASE 6
e$ = e$ + "L16" + en$(5) + en$(5)
numnote = numnote - 2
CASE 7
e$ = e$ + "L16" + en$(5) + en$(5) + "L8" + en$(5)
numnote = numnote - 3
CASE 8
e$ = e$ + "L8" + en$(5) + "L16" + en$(5) + en$(5)
numnote = numnote - 3
CASE 9
e$ = e$ + "L8" + en$(5) + en$(5)
numnote = numnote - 2
CASE 10
e$ = e$ + "L8" + enft$(1, 2) + en$(5)
numnote = numnote - 2
CASE 11
e$ = e$ + "L32" + en$(2) + "V25" + en$(5) + en$(2) + "V50" + en$(5)
numnote = numnote - 4
CASE 12
e$ = e$ + "L32" + en$(1) + "V25" + en$(5) + "V50" + en$(2) + en$(5)
numnote = numnote - 4
CASE 13
e$ = e$ + "L32" + en$(5) + "V25" + en$(5) + "V50L16" + en$(5)
numnote = numnote - 3
CASE 14
e$ = e$ + "L16" + en$(5) + "L32" + en$(5) + "V25" + en$(5)
numnote = numnote - 3
CASE 15
e$ = e$ + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 16
e$ = e$ + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 17
e$ = e$ + "L16" + en$(5) + "V25" + en$(5) + "V50L8" + en$(5)
numnote = numnote - 3
CASE 18
e$ = e$ + "L8" + en$(5) + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 3
CASE 19
e$ = e$ + "L8" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 20
e$ = e$ + "L8" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
END SELECT
LOOP WHILE numnote > athird * 2

DO
e$ = e$ + "V50"
u = Random1(20)
SELECT CASE u
CASE 1
e$ = e$ + "L32" + anft$(1, 2) + anft$(1, 5) + anft$(1, 2) + anft$(1, 5)
numnote = numnote - 4
CASE 2
e$ = e$ + "L32" + anft$(1, 2) + anft$(1, 5) + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 4
CASE 3
e$ = e$ + "L32" + anft$(1, 2) + anft$(3, 5) + "L16" + anft$(1, 2)
numnote = numnote - 3
CASE 4
e$ = e$ + "L16" + anft$(1, 2) + "L32" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 3
CASE 5
e$ = e$ + "L16" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 2
CASE 6
e$ = e$ + "L16" + anft$(1, 5) + anft$(1, 5)
numnote = numnote - 2
CASE 7
e$ = e$ + "L16" + anft$(1, 2) + anft$(3, 5) + "L8" + anft$(1, 2)
numnote = numnote - 3
CASE 8
e$ = e$ + "L8" + anft$(1, 2) + "L16" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 3
CASE 9
e$ = e$ + "L8" + anft$(1, 2) + anft$(3, 5)
numnote = numnote - 2
CASE 10
e$ = e$ + "L8" + anft$(1, 5) + anft$(1, 5)
numnote = numnote - 2
CASE 11
e$ = e$ + "L32" + anft$(1, 2) + "V25" + anft$(1, 5) + "V50" + anft$(1, 2) + "V25" + anft$(1, 5)
numnote = numnote - 4
CASE 12
e$ = e$ + "L32" + anft$(1, 2) + "V25" + anft$(1, 5) + "V50" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 4
CASE 13
e$ = e$ + "L32" + anft$(1, 2) + "V25" + anft$(3, 5) + "V50L16" + anft$(1, 2)
numnote = numnote - 3
CASE 14
e$ = e$ + "L16" + anft$(1, 2) + "V25L32" + anft$(1, 2) + "V50" + anft$(3, 5)
numnote = numnote - 3
CASE 15
e$ = e$ + "L16" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 2
CASE 16
e$ = e$ + "L16" + anft$(1, 5) + "V25" + anft$(1, 5)
numnote = numnote - 2
CASE 17
e$ = e$ + "L16" + anft$(1, 2) + "V25" + anft$(3, 5) + "V50L8" + anft$(1, 2)
numnote = numnote - 3
CASE 18
e$ = e$ + "L8" + anft$(1, 2) + "L16" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 3
CASE 19
e$ = e$ + "L8" + anft$(1, 2) + "V25" + anft$(3, 5)
numnote = numnote - 2
CASE 20
e$ = e$ + "L8" + anft$(1, 5) + "V25" + anft$(1, 5)
numnote = numnote - 2
END SELECT
LOOP WHILE numnote > athird

DO
e$ = e$ + "V50"
u = Random1(20)
SELECT CASE u
CASE 1
e$ = e$ + "L32" + en$(2) + en$(5) + en$(2) + enft$(3, 5)
numnote = numnote - 4
CASE 2
e$ = e$ + "L32" + en$(2) + enft$(3, 5) + en$(2) + enft$(3, 5)
numnote = numnote - 4
CASE 3
e$ = e$ + "L32" + en$(5) + en$(5) + "L16" + en$(5)
numnote = numnote - 3
CASE 4
e$ = e$ + "L16" + en$(5) + "L32" + en$(5) + enft$(3, 5)
numnote = numnote - 3
CASE 5
e$ = e$ + "L16" + en$(5) + en$(5)
numnote = numnote - 2
CASE 6
e$ = e$ + "L16" + en$(2) + enft$(3, 5)
numnote = numnote - 2
CASE 7
e$ = e$ + "L16" + en$(2) + enft$(3, 5) + "L8" + en$(5)
numnote = numnote - 3
CASE 8
e$ = e$ + "L8" + en$(5) + "L16" + en$(2) + enft$(3, 5)
numnote = numnote - 3
CASE 9
e$ = e$ + "L8" + en$(2) + en$(5)
numnote = numnote - 2
CASE 10
e$ = e$ + "L8" + en$(2) + enft$(3, 5)
numnote = numnote - 2
CASE 11
e$ = e$ + "L32" + en$(2) + "V25" + en$(5) + "V50" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 4
CASE 12
e$ = e$ + "L32" + en$(2) + "V25" + enft$(3, 5) + en$(2) + "V50" + enft$(3, 5)
numnote = numnote - 4
CASE 13
e$ = e$ + "L32" + en$(5) + "V25" + en$(5) + "V50L16" + en$(5)
numnote = numnote - 3
CASE 14
e$ = e$ + "L16" + en$(5) + "V25L32" + en$(5) + "V50" + enft$(3, 5)
numnote = numnote - 3
CASE 15
e$ = e$ + "L16" + en$(5) + "V25" + en$(5)
numnote = numnote - 2
CASE 16
e$ = e$ + "L16" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 2
CASE 17
e$ = e$ + "L16" + en$(2) + "V25" + enft$(3, 5) + "V50L8" + en$(5)
numnote = numnote - 3
CASE 18
e$ = e$ + "L8" + en$(5) + "L16" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 3
CASE 19
e$ = e$ + "L8" + en$(2) + "V25" + en$(5)
numnote = numnote - 2
CASE 20
e$ = e$ + "L8" + en$(2) + "V25" + enft$(3, 5)
numnote = numnote - 2
END SELECT
LOOP WHILE numnote > 0

PLAY e$

DO WHILE PLAY(0) > 0
_LIMIT 600
IF _KEYDOWN(32) THEN EXIT DO
IF _KEYDOWN(27) THEN EXIT DO
LOOP
IF _KEYDOWN(27) THEN EXIT FOR
DO : LOOP WHILE _KEYDOWN(32)
NEXT 'song

SYSTEM


scaleslist:
DATA "3334","3344","3444","3445","3454","3545","4545","4543","3456","4565","4546"
DATA "4556","4666","5666","5444","5334","5355","5463","6444","6445","6366","6463"
DATA "END"


FUNCTION en$ (topval AS INTEGER)
en$ = "N" + _TRIM$(STR$(thiscale(Random1(topval))))
END FUNCTION

FUNCTION enft$ (fromval AS INTEGER, totoval AS INTEGER)
enft$ = "N" + _TRIM$(STR$(thiscale(Rand(fromval, totoval))))
END FUNCTION

FUNCTION anft$ (fromval AS INTEGER, totoval AS INTEGER)
anft$ = "N" + _TRIM$(STR$(altscale(Rand(fromval, totoval))))
END FUNCTION


FUNCTION Rand& (fromval&, toval&)
DIM sg%, f&, t&
IF fromval& = toval& THEN
Rand& = fromval&
EXIT FUNCTION
END IF
f& = fromval&
t& = toval&
IF (f& < 0) AND (t& < 0) THEN
sg% = -1
f& = f& * -1
t& = t& * -1
ELSE
sg% = 1
END IF
IF f& > t& THEN SWAP f&, t&
Rand& = INT(RND * (t& - f& + 1) + f&) * sg%
END FUNCTION

FUNCTION Random1& (maxvaluu&)
DIM sg%
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
Random1& = 0
ELSE
IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION

One fault with this program is that it doesn't play phrases (or "hooks", don't know how to say it out of the popular music industry) so one could recognize which song it is LOL. This program creates music which is too random. I programmed the "phrases" thing half-successfully with my Lua script for "1bitr". With "phrases" this program could make a good companion to bplus' program indicated in this thread:

https://qb64phoenix.com/forum/showthread.php?tid=1668

Purposely I set the songs playing fairly fast, ie. using "L32" instead of "L16" that I preferred, however PLAY statement doesn't allow tempos higher than 255. The logic of this program isn't very good for computing music with lengths and amplitude, which could be improved.
Reply
#2
@mnrvovrfc hmm... that code plays for you
   

Animating music sounds fun!
b = b + ...
Reply
#3
Cannot reproduce it, but I made a fix in case the note value goes higher than 84 in either of the scales...

I changed my first post.
Reply
#4
Line 61   e$ = e$ + "@" + _Trim$(Str$(Random1(3)))   
I am not finding @ on Play Commands List.

@mnrvovrfc  Did the forum editor change your code?

More found:
Stepping through code with Play e$ I found this:
Code: (Select All)
    e$ = "MB"
    If Random1(3) = 1 Then e$ = e$ + "MS" Else e$ = e$ + "MN"
    e$ = e$ + "T" + _Trim$(Str$(Rand(9, 16) * 10))
    Play e$
    ' e$ = e$ + "@" + _Trim$(Str$(Random1(3)))

    Play e$

    e$ = e$ + "Q10V50"

    Play e$

No Q in PLAY Commands list either.

Update again: when I dump both lines it plays stuff, not very musical. Probably missing something intended in those 2 lines I commented out.

BTW! when I try gymmjack's version and even more this crazy random stuff I am reminded of my code for Integers set to music by lowest prime divisor.
b = b + ...
Reply
#5
OK with further fiddling around (pun intended)
Code: (Select All)
    e$ = e$ + "T" + _Trim$(Str$(Rand(9, 16) * 10))
    e$ = e$ + "O" + _Trim$(Str$(Random1(3)))
    e$ = e$ + "P10V50"

The first letters after e$ = e$ +
Are T, O, P  and "musak!" plays...

https://www.youtube.com/watch?v=H6_eqxh-Qok
b = b + ...
Reply
#6
Music 
OK I wrote a slightly better version which doesn't use cryptic "N" commands LOL.

Code: (Select All)

'by mnrvovrfc 20-June-2023
'works in QB64 Phoenix Edition v3.8 and later
'otherwise see below
OPTION _EXPLICIT

DIM frag(1 TO 48) AS STRING
DIM scales(1 TO 2, 1 TO 5) AS INTEGER
DIM phrase(1 TO 10) AS STRING
DIM AS INTEGER basenote, numfrag, n, vu, ve, u, a, b, c, d
DIM AS INTEGER x, y
DIM e$, notes$, nop$, ncl$, double1 AS _BYTE, double2 AS _BYTE
DIM setdot AS _BYTE

notes$ = "C C#D D#E F F#G G#A A#B "

RANDOMIZE TIMER

double1 = Random1(2) - 1
double2 = Random1(2) - 1
FOR y = 1 TO 2
basenote = Random1(12) * 2 - 1
FOR x = 1 TO 5
scales(y, x) = basenote
basenote = basenote + Rand(3, 6) * 2
NEXT
NEXT

vu = 0
ve = 0
FOR y = 1 TO 32
setdot = 0
u = Random1(10)
SELECT CASE u
CASE 1: e$ = "L4~~"
CASE 2: e$ = "L8~~~~"
CASE 3: e$ = "L4~L8~~"
CASE 4: e$ = "L8~~L4~"
CASE 5: e$ = "L8~L4~L8~"
CASE 6: e$ = "L16~~L8~L4~"
CASE 7: e$ = "L16~~~~L4~"
CASE 8: e$ = "L8~~L16~~~~"
CASE 9: e$ = "L8~L16~~L8~L16~~"
CASE 10
setdot = 1
e$ = "L4~L16~"
END SELECT

setdot = 0
x = CountString(e$, "~")
n = scales(1, Random1(2))
DO WHILE x > 0
nop$ = ""
ncl$ = ""
DO WHILE n > 23
nop$ = nop$ + ">"
ncl$ = ncl$ + "<"
n = n - 24
LOOP
'if not QB64PE might have to remove this IF statement:
IF Random1(3) = 1 THEN
DO
vu = Random1(3)
LOOP WHILE vu = ve
ve = vu
SELECT CASE vu
CASE 1: nop$ = nop$ + "V50"
CASE 2: nop$ = nop$ + "V25"
CASE 3: nop$ = nop$ + "V12"
END SELECT
END IF
IF setdot THEN
setdot = 0
nop$ = nop$ + RTRIM$(MID$(notes$, n, 2)) + "." + ncl$
ELSE
nop$ = nop$ + RTRIM$(MID$(notes$, n, 2)) + ncl$
END IF
ReplaceString2 e$, "~", nop$, 1
n = scales(1, Random1(5))
x = x - 1
LOOP
frag(y) = e$
NEXT

vu = 0
ve = 0
FOR y = 33 TO 48
u = Random1(10)
SELECT CASE u
CASE 1: e$ = "L4~~"
CASE 2: e$ = "L8~~~~"
CASE 3: e$ = "L4~L8~~"
CASE 4: e$ = "L8~~L4~"
CASE 5: e$ = "L8~L4~L8~"
CASE 6: e$ = "L16~~L8~L4~"
CASE 7: e$ = "L16~~~~L4~"
CASE 8: e$ = "L8~~L16~~~~"
CASE 9: e$ = "L8~L16~~L8~L16~~"
CASE 10
setdot = 1
e$ = "L4~L16~"
END SELECT

x = CountString(e$, "~")
DO WHILE x > 0
n = scales(2, Random1(5))
nop$ = ""
ncl$ = ""
DO WHILE n > 23
nop$ = nop$ + ">"
ncl$ = ncl$ + "<"
n = n - 24
LOOP
'if not QB64PE might have to remove this IF statement:
IF Random1(3) = 1 THEN
DO
vu = Random1(3)
LOOP WHILE vu = ve
ve = vu
SELECT CASE vu
CASE 1: nop$ = nop$ + "V50"
CASE 2: nop$ = nop$ + "V25"
CASE 3: nop$ = nop$ + "V12"
END SELECT
END IF
IF setdot THEN
setdot = 0
nop$ = nop$ + RTRIM$(MID$(notes$, n, 2)) + "." + ncl$
ELSE
nop$ = nop$ + RTRIM$(MID$(notes$, n, 2)) + ncl$
END IF
ReplaceString2 e$, "~", nop$, 1
x = x - 1
LOOP
frag(y) = e$
NEXT

e$ = "MBMNT" + _TRIM$(STR$(Rand(9, 16) * 10)) + "@" + _TRIM$(STR$(Random1(3))) + "O3"
'use this line instead for earlier QB64PE, or for other QB64:
'e$ = "MBMNT" + _TRIM$(STR$(Rand(9, 16) * 10)) + "O3"
_TITLE "Press [ESC] to quit."

numfrag = Rand(6, 16)
n = numfrag
FOR x = 1 TO 5
a = Random1(10)
b = Random1(10)
c = Random1(10)
d = Random1(10)
phrase(x) = frag(a) + frag(b) + frag(c) + frag(d)
IF double1 AND x < 3 THEN phrase(x) = phrase(x) + frag(a) + frag(b) + frag(c) + frag(d)
NEXT
FOR x = 6 TO 10
a = Rand(33, 40)
b = Rand(33, 40)
c = Rand(33, 40)
d = Rand(33, 40)
phrase(x) = frag(a) + frag(b) + frag(c) + frag(d)
IF double2 AND x < 3 THEN phrase(x) = phrase(x) + frag(a) + frag(b) + frag(c) + frag(d)
NEXT

n = numfrag
u = 11
DO WHILE n > 0
a = advanceu(11, 24, u)
b = advanceu(11, 24, u)
c = advanceu(11, 24, u)
d = advanceu(11, 24, u)
e$ = e$ + phrase(Random1(5)) + frag(a) + frag(b) + frag(c) + frag(d)
n = n - 1
LOOP

u = Rand(33, 40)
n = numfrag
DO WHILE n > 0
a = advanceu(33, 48, u)
b = advanceu(33, 48, u)
c = advanceu(33, 48, u)
d = advanceu(33, 48, u)
e$ = e$ + phrase(Random1(5) + 5) + frag(a) + frag(b) + frag(c) + frag(d)
n = n - 1
LOOP

u = Rand(11, 24)
n = numfrag
DO WHILE n > 0
a = advanceu(11, 32, u)
b = advanceu(11, 32, u)
c = advanceu(11, 32, u)
d = advanceu(11, 32, u)
e$ = e$ + phrase(Random1(5)) + frag(a) + frag(b) + frag(c) + frag(d)
n = n - 1
LOOP

CLS
IF LEN(e$) <= 1596 THEN
PRINT e$
ELSE
PRINT LEFT$(e$, 1596); "..."
END IF
PLAY e$
_CLIPBOARD$ = e$

DO WHILE PLAY(0) > 0
_LIMIT 600
IF _KEYDOWN(27) THEN EXIT DO
LOOP

SYSTEM


'CHANGED: u
FUNCTION advanceu% (fromval AS INTEGER, totoval AS INTEGER, u AS INTEGER)
u = u + 1
IF u > totoval THEN u = fromval
advanceu% = u
END FUNCTION


FUNCTION Rand& (fromval&, toval&)
DIM sg%, f&, t&
IF fromval& = toval& THEN
Rand& = fromval&
EXIT FUNCTION
END IF
f& = fromval&
t& = toval&
IF (f& < 0) AND (t& < 0) THEN
sg% = -1
f& = f& * -1
t& = t& * -1
ELSE
sg% = 1
END IF
IF f& > t& THEN SWAP f&, t&
Rand& = INT(RND * (t& - f& + 1) + f&) * sg%
END FUNCTION

FUNCTION Random1& (maxvaluu&)
DIM sg%
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
Random1& = 0
ELSE
IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION

SUB ReplaceString2 (tx AS STRING, sfind AS STRING, repl AS STRING, numtimes AS _UNSIGNED LONG)
DIM AS STRING s, t
DIM AS _UNSIGNED LONG ls, lx, count, u
DIM goahead AS _BYTE
IF (tx = "") OR (sfind = "") OR (sfind = repl) OR (LEN(sfind) > LEN(tx)) THEN EXIT SUB
s = UCASE$(sfind): t = UCASE$(tx)
ls = LEN(s)
count = 0
goahead = 1
DO
u = INSTR(t, s)
IF u > 0 THEN
tx$ = LEFT$(tx, u - 1) + repl + MID$(tx, u + ls)
t = UCASE$(tx)
IF numtimes > 0 THEN count = count + 1: IF count >= numtimes THEN goahead = 0
ELSE
goahead = 0
END IF
LOOP WHILE goahead
END SUB

FUNCTION CountString% (tx$, delim$)
DIM AS LONG count, z1, z2, lx
IF (tx$ = "") OR (delim$ = "") THEN
CountString% = 0
EXIT FUNCTION
END IF
lx = LEN(delim$)
z1 = 1
z2 = INSTR(tx$, delim$)
count = 0
DO UNTIL z2 = 0
count = count + 1
z1 = z2 + lx
z2 = INSTR(z1, tx$, delim$)
LOOP
CountString% = count
END FUNCTION

There's no way that I know to cause it to stop playing the current song. Unfortunately, it means this program plays one song at a time; either it ends or the user presses [ESC]. The logic that handles note amplitude is lame, could be better. I was trying to make sure the "phrases" are emphasized so this becomes less like random musak and more like pop-rock or freeform jazz or something else.

As an added bonus the generated song is copied to the text clipboard. <3

I got an "Illegal function call" from trying to use "L4." or something alike. It seems QB64 expects the dot after a note like "C#4." or "F." which is clumsier to program. If you take a closer look at this program, all the small fragments of music are the same music duration. Therefore, must take that into consideration when inserting the dot.
Reply
#7
Quote:OK I wrote a slightly better version which doesn't use cryptic "N" commands LOL.

N commands meaning the number variable values for substitutions? 

Quote:'by mnrvovrfc 20-June-2023
'works in QB64 Phoenix Edition v3.8 and later

What changes made this code v3.8 and later? Was there a change in Play command?
It certainly is not better in 3.7 Windows OS:
   

@mnrvovrfc you never answered about the @ and Q symbols used in your first post that aren't part of PLAY commands?
I am suspecting you pulled something from FB or other Basic, if the forum editor didn't change your code, the [ qb ] tags BTW!

Perhaps you wish to keep the mystery going LOL!
b = b + ...
Reply
#8
You're using QB64PE v3.7. (shrugs)

The "Q" and "@" commands were added for v3.8. Now it's beyond my control if it doesn't work for you for the new version.

You were really quick, I wanted to post a correction to the code I just posted. The previous created songs too long and I desired to fix the inability to play dotted-length notes. So check out the post #5 above.

The "N" command for PLAY, to play a note according to MIDI note number from zero to 84. In this new approach I did something that looks better like composed music with note commands.
Reply
#9
Yeah just found it here:
https://qb64phoenix.com/forum/showthread...2#pid16722

Quote:#347 - Audio enhancements. - @a740g
  • Updates miniaudio to v0.11.17, which adds support for Apple AIFF and AIFC audio formats. So, we get those too.
  • PLAY has been extended to:
    • Select waveforms @n (square = 1, sawtooth = 2, triangle = 3 (default), sine = 4, noise = 5).
    • Adjust volume ramping Qn (0ms to 100ms).


You are forcing my lazy ass to get 3.8 LOL!

I hope someone can help us with the stopping!
You got to be careful starting something hard to stop ie drugs like cocaine, sugar and QB64 Smile
b = b + ...
Reply
#10
It's really not a big deal. Just edit away the code that creates the "@" and "Q" commands, and maybe the "V50" and similar stuff. You could post this code into the other forum on my behalf. Or after you make modifications as you feel like because it's very boring visually. Smile

When I started this thread I posted in the old "code" tags. Then when I went to edit my first post for changes in the code I switched to the "cue-bee" tags. I'm sorry if it confounded anybody else.
Reply




Users browsing this thread: 4 Guest(s)