{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Propeller Signal Generator v1.2 (C) 2012 Johannes Ahlebrand │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ TERMS OF USE: Parallax Object Exchange License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ } CON MUTE = 14, SAW = 16, TRIANGLE = 18, SQUARE = 22, NOISE = 25, SINE = 32, USER = 42, PW50 = 1<<31, PW25 = 1<<30, PW12_5 = 1<<29, freqRef = 536870912 VAR byte cog long waveform, frequency, damplevel, pulseWidth, userWaveformP, userWaveformSize PUB start(outPin, invertedPin, syncPin) ' ┌──────────────────────────────────────────────────────────────┐ ' │ Starts PSG in a single cog │ ' ├──────────────────────────────────────────────────────────────┤ ' │ outPin - The pin to output the signal on │ ' │ invertedPin - The pin to output the inverted signal on │ ' │ syncPin - The pin to output the synchronization signal on│ ' └──────────────────────────────────────────────────────────────┘ stop waveform := MUTE regCounter := $1C000000 | outPin | (invertedPin<<9) noiseValue := $10000000 '| syncPin delayLine := (1<>1 cmpVal long $FFFF dcOffset long 1<<31 maxAmplitude long(1<<31)-1 val512 long 1<<9 regCounter long 1 noiseValue long 1 delayLine long 1 waveform_ res 1 frequency_ res 1 damplevel_ res 1 pulseWidth_ res 1 userWaveformP_ res 1 userWaveformSize_ res 1