|
Forum Index : Microcontroller and PC projects : Micromite Musical Box
| Author | Message | ||||
| MikeO Senior Member Joined: 11/09/2011 Location: AustraliaPosts: 275 |
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 ZealandPosts: 9755 |
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 KingdomPosts: 10572 |
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 ZealandPosts: 9755 |
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! |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |