Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:07 13 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite Musical Box

     Page 2 of 2    
Author Message
MikeO
Senior Member

Joined: 11/09/2011
Location: Australia
Posts: 275
Posted: 12:49pm 11 Dec 2015
Copy link to clipboard 
Print this post

OK everyone thanks for the answers, all makes sense, no good for my use unfortunately so I have written a little sound(note,duration) sub which works good for my use.

Thanks again.
Codenquilts
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9755
Posted: 01:55am 24 Jun 2019
Copy link to clipboard 
Print this post

I am having issues making this Cfunction work in MMBASIC 5.0501.

I keep getting 'Number too large' errors whenever I try to play a sound.

My code:


DIM NOTE1!,NOTE2!,DURATION!,RTN%
Dim SW%(31)=(8,9,10,12,13,14,14,15,15,15,14,14,13,12,10,9,7,6,5,4,2,1,1,0,0,0,1,1,2,3,5,6) 'Sinewave table for SOUND Cfunction

...

Sub BEEPER
NOTE1!=500:NOTE2!=250:DURATION!=0.2
Do
For A=1 To 2
RTN%=SOUND(NOTE1!,DURATION!,SW%())
RTN%=SOUND(NOTE2!,DURATION!,SW%())
Next
Loop
End Sub

...

'Here is a CFunction that outputs a sine wave of a specified frequency for a specified length of time
'using the CVREF output on the Micromite (pin-23 of the 64-bit MM+, pin-29 on the 100 pin MM+,
'pin 25 of a 28-pin uM2 and pin 14 on a 44-pin uM2).
'X=SOUND(A,D,SW%())
'Dim SW%(31)=(8,9,10,12,13,14,14,15,15,15,14,14,13,12,10,9,7,6,5,4,2,1,1,0,0,0,1,1,2,3,5,6)
CFunction SOUND
00000000
27BDFFD0 AFBF002C AFB50028 AFB40024 AFB30020 AFB2001C AFB10018 AFB00014
00A08821 00C09021 3C109D00 8E140058 8C930000 8E02009C 0040F809 3C044200
02602021 0280F809 00402821 0040A821 8E140064 8E030000 8E020080 8C640000
0040F809 00002821 00409821 8E02009C 0040F809 3C044000 02602021 0280F809
00402821 00409821 8E14007C 8E020058 8E240000 0040F809 02602821 0280F809
00402021 00408821 8E14007C 8E020064 02602021 0040F809 02A02821 0280F809
00402021 00001821 40834800 0071182B 14600013 00405021 10000018 34048000
40034800 0065202B 1480FFFD 00000000 00A22821 8CE40000 34848040 AD249800
24C60001 14C8FFF6 24E70008 0071182B 14600006 014B5021 10000008 34048000
3C09BF81 24080020 00025940 02403821 01402821 1000FFEA 00003021 3C03BF81
AC649804 00001821 8FBF002C 8FB50028 8FB40024 8FB30020 8FB2001C 8FB10018
8FB00014 03E00008 27BD0030
End CFunction


Whenever I call the BEEPER routine, the code falls over when trying to play the first note. 'Number too large.' I was seeing that initially when this Cfunction was released, but I thought if the numbers were passed as floats, and the dummy return was a 64-bit integer, you had no problems....

Yes, variable 'A' is also defined, but just as a plain integer, which should suffice for a simple two step loop.

matherp - can you perhaps hint at what I am doing wrong here?
Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 06:55am 24 Jun 2019
Copy link to clipboard 
Print this post

  Quote  can you perhaps hint at what I am doing wrong here?


The code will no longer run on the MM+ as Geoff has changed floating point numbers to doubles in recent releases
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9755
Posted: 07:04am 24 Jun 2019
Copy link to clipboard 
Print this post

Damn....

Thanks though, cos now at least I know and can stop trying to make it work.
I might roll back to 5.0408 - I think it was working OK in that release...
Smoke makes things work. When the smoke gets out, it stops!
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025