creating arrays
hitsware
Posts: 156
what would be the most elegant way (pbasic)
to do this (qbasic):
(# elements in array statement(I forget right now))
for x=0 to 7
read n(x)
next x
data 24,27,30,32,36,40,45,48
to do this (qbasic):
(# elements in array statement(I forget right now))
for x=0 to 7
read n(x)
next x
data 24,27,30,32,36,40,45,48
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
How do you get rid of the annoying 'pop'
At the end of the loop?
loop
freqout 0,1000,1000
goto loop
That's why I want to find a way to have one pin
connected to one of the '3' timers
Can the other 2 do the 'pulsout' et. al. ?
That way you can fire an external envelope generator
AFTER!
The annoying pop ..... (
you lost me
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Regarding the "pop" ... Read the section of the PBasic manual on the FREQOUT statement. It discusses the need for a low pass filter on the output pin of the Stamp. If the values in the filter are suitable for the frequencies involved, the "pop" should be well attenuated.
As I mentioned before, there is no way to get access to the timers. The Stamp is a "single threaded" processor and can only do one thing at a time. Some functions, such as controlling a servo, can be combined with others only because there's time between servo pulses to do other things.
if you listen (though an amplifier) to pin 0 in the example you'll hear a 'pop' every 1000 'duration units'
It runs on my system.
>If you're using the old (default) syntax, then "loop"
>requires a colon after it to make it a valid label. If
>you're using the version 2.5 syntax, "loop" becomes
>a reserved word (along with DO to make a looping
>construct) and the goto would be invalid.
I use the stamp2.exe with the most popular stamp.
It sounds like you're unhappy with how the Stamp works. Some things it does superbly and some things it does barely adequately. Some things (like multitasking) it doesn't do at all even though sometimes you can "fake it".
Maybe for your project you need a different microcontroller. Parallax does sell two other kinds, the SX and the Propeller. Both do multitasking, the Propeller particularly well. As I noted in your other thread, there are already several very sophisticated sound processing / synthesis programs already written, one for vocal tract synthesis that's particularly impressive.
>to get access to the timers. The Stamp is
>a "single threaded" processor and can only
>do one thing at a time. Some functions,
>such as controlling a servo, can be combined
>with others only because there's time
>between servo pulses to do other things.
Doe any one make someting like the 'BU8763'
chip in a dip package?
Or a 'BU8763' on a dip header?
Not at all. I may have been wishing for more, but I can't knock success.
The 'freqout' with 2 possible notes is pretty powerfull.
I've ran into the 'pop' before
(when you hear a sudden change in frequency (+ the glitch while the channel updates))
Finally pretty well cured it on the opl3 .....
The envelope needs to start after the frequency shift.
I have the LP filter. Plus a HP to keep DC shifts out of
the signal.
I hope the adapter works for you. DigiKey also has some similar adapters in their catalog. They're on a much thinner PCB. The SparkFun ones are physically stronger and more suitable for breadboard use.
Would one of the 6 (or 8) pin Microchip chips be able to do the 'freqout' command? or at least a 'sound' (squarewave)?
If I could attach 3 or 4 of those to 3 or 4 pins on the stamp that might do the trick.....
I'm sure any of the Microchip processors can handle putting out a sequence of pulses or a squarewave signal anywhere in the audio range. If you're familiar with their programming, have at it. There are a number of 3rd parties that use PIC processors for various peripheral tasks for Stamps and other similar microcontrollers.
10 dim n(4) ' gives the note 4 possibilities
20 for x=0 to 3 ' x is automaticly a variable
30 read n(x) ' n has been declared
40 next x
50 data: 1,2,3,4 ' maybe you don't number the 'data' lines?
Anyways .......
Is this what you were lookubg for?
PBASIC
n VAR BYTE(4) ' gives the note 4 possibilities
x VAR NIB
for x=0 to 3 ' x is automaticly a variable
read n(x) ' n has been declared
next
data: 1,2,3,4
END
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I would think so, but I get a "expected ' , ' " (expected comma)
error after the read statement ?
n var byte(4)
x var nib
for x=0 to 3
read n(x)
next
data: 1,2,3,4
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Sorry, I don't have the Stamp Editor or any of my Stamp documentation on this particular computer. It was my error, however. It should have read something like the following, but check the syntax in the PBASIC Help Fle:
n var byte(4)
x var nib
for x=0 to 3
n(x) = read x
next
data: 1,2,3,4
END
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
LOOKUP is much more efficient because it's indexed; therefore the data it doesn't need to be loaded into an array.
PBasic's READ and DATA statements are also an indexing systems good for really large multidimensional tables and arrays.
The problem with the old QBASIC command is that there isn't that much memory to make it useful in larger programming tasks.
As for your freqout problem let me point out that :
May differ with your processor and you may have to adjust your durations to be a multiple of your frequency units.
·a 440 hZ tone would have a wavelength of 2.272727..... milliseconds. A BS2 loop of:
freqout 0,1000,440
loop
would pop & click but a loop of
freqout 0,1314,440
loop
would not as much - if filtered properly. see Freqout in the help file. Due to the inaccuracy of the BS2 the actual number should be 1320·but its not.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 4/7/2007 5:55:00 PM GMT
>A BS2 loop of:
do
freqout 0,1000,440
loop
>would pop & click but a loop of
do
freqout 0,1314,440
loop
.....yea .... thanks ...... i think i ran into something like that on an Amiga [noparse]:)[/noparse]
c var nib (4):n var nib(4):x var nib:y var nib
for x=0 to 3:read cx+x,c(x):read nx+x,n(x):next
play:for x=0 to 3:for y=0 to 3
freqout 0,400,c(x)*n(y)*8,c(x)*n(y)*16
next[noparse]:next:[/noparse]goto play
' Thanks everybody. This is going to work [noparse]:)[/noparse]
' Listen to pin 0