Wicker,
I'm saving all cog register RAM on entry and restoring it on return. I do not use the CORDIC or the LUT. I'm pretty sure that I'm messing up something FastSpin specific. I think it is the "objptr" (FastSpins internal data pointer) that gets used before the previous add/sub sequence is finishen. That makes it point to an offset instead of the baseline.
I just wanted to post a little sound engine that can play music and sound effects at the same time. It's basically an abstraction layer for reSound + a module player in one package. It hides all complicated details about mixing frequency and configuration parameters and stuff. Just specify which smart pin numbers to use for stereo output, attach a module file and some samples and you are off.
Features:
* Is totally clock frequency agnostic and will adapt the mixing frequency accordingly while playing samples at the right rate
* Using a clock frequency of 252 MHz and a total of 12 sample channels (default), the mixing frequency is a respectable 218 kHz
* Has got 8 dedicated sample channels by default, but that can easily be changed to anything (8 is enough for most things)
* Has got 4 dedicated sample channels for music playback
* Has got a simple and easy API
* Compiles fine with both Chips interpreter and FastSpin
Enjoy!
(this object is just a stepping stone to the real sound engine I want to make... stay tuned)
' NOW let's set the new parameters
long[inputHandle][3] := loopSize << phaseAccuShift ' Loop size
long[inputHandle][2] := -bufferSizeShl ' Trigger offset
long[inputHandle][1] := samplePtr - ptrAdjustment ' Buffer pointer, non zero values starts the phase accumulation again long[inputHandle][5].[2] := false ' Enable the buffer pointer + phase accumulator calculation again
Thanks, that seems to work - I can hear all three demos working, axelf playing, something that sounds like a game, and and a weird combination of music and sound fx etc in the advanced demo.
Very cool stuff as usual Ahle2! I gotta get you the HyperRAM driver asap so you can work it into your playback for large mod files etc. We just need a good way to get large amounts of code/data loaded into there given the limited 512k binary size on the P2 itself. Maybe we need a modification to loadp2 or something, or a way to use the SD, though that is less convenient to have to remove/re-install each time etc.
I'm confident that it is going to be very useful for audio especially with that large 32MB area for wavetable samples in HyperFlash that can be read really quickly into HUB etc.
or a way to use the SD, though that is less convenient to have to remove/re-install each time etc.
proploader for P1 has a feature where it can download files to the SD card over serial. It's really slow, but that has more to do with the low baudrate used. A similar thing could be made for P2. Could probably handle 3Mbaud with ease.
Yeah ideally there would be a way to load stuff into HyperRAM and/or HyperFlash via something small loaded into the P2 first that acts as a download client/helper. This should be possible to run pretty fast. Address management becomes a bit of an issue then though as it needs to be coupled into the tool's download commands etc.
Those were late changes that I made after I switched to get it working in Chips interpreter. It seems like FastSpin doesn't like bit fields?!
Just uncomment those lines and it should almost work the same, just possbile some extra glitches when a sample starts playing.
Fastspin is OK with bit fields on variables and simple array references, but not with the example you gave. "long[inputHandle+20].[2]" should work though. *EDIT* there's a problem with that too. With fastspin 4.3.1 you'll have to use "long[inputHandle][5] |= 4". All of the forms should be fixed in github now though.
Very cool stuff as usual Ahle2! I gotta get you the HyperRAM driver asap so you can work it into your playback for large mod files etc.
Thanks! Yeah, I would really like to get hold of your driver to do some cool stuff. It will be very useful. You have made a tremendous lot of work on that one (as far as I understand reading the thread from time to time) and it will benefit the whole community in the end. Your video driver is ace as well. Thanks for your contributions!
@Wuerfel_21
What are you up to on the P2? I know you did some cool video drivers and even a game that sadly never got released for the P1. It all looked very promising!
@ersmith
Thanks for the fix! When will there be a new version of FastSpin that includes this? Or do I have to compile it myself?
@Wuerfel_21
What are you up to on the P2? I know you did some cool video drivers and even a game that sadly never got released for the P1. It all looked very promising!
Just backseat coding right now - don't have a P2 here yet - EU P2 shipping is apparently very expensive - and I assume the entire thing will get a bit cheaper when production silicon comes out.
Also, I'm still working on the game - it just goes slowly. Currently somewhat stuck on deciding the overall plot and structure (one of the reasons I decided to have a break in July, wherein I made Spin Hexagon (1080p P2 port when?) ), so I'm mostly doing random bits of programming (like writing a custom parser for GraphicsGale's proprietary layered file format to automate the generation of character face sets from layered files... I don't think I ever posted a video of the dialog system in action?) and drawing the odd graphic right now. Also have like 2 tunes that need converting to Retronitus format (and one that I need to revisit, I kinda got frustrated with - otoh I left like 4 more tunes worth of unfitting-yet-good bits in that file, hah)
But ah, perseverance is a virtue or smth (I'm up to 14370 non-blank,non-comment lines of .rasm files (mixed ASM and compile-time Ruby (used as "super macros" of sorts)) right now - a couple thousand more if I'd also count the native P1 code, the helper scripts, the map editor and the high-level emulator I wrote...)
Wow, you have spent a lot of time and energy on those projects! Do you have some videos of your Zelda clone in action with Retronitus sound? I never got to the point where Retronitus got incorporated into a real game, even though that was the driving force when I started working on it. I'm really looking forward to you joining the P2 community for real (when you get the HW) and start doing some retro game coding on this superior microcontroller. I wish Baggers could come back to the forums as well, with all his commercial retro game coding experience. I know that he has got too much going on with the Spectrum Next to have any time over for the P2. (I have had a brief email conversation with him lately)
Wow, you have spent a lot of time and energy on those projects! Do you have some videos of your Zelda clone in action with Retronitus sound? I never got to the point where Retronitus got incorporated into a real game, even though that was the driving force when I started working on it. I'm really looking forward to you joining the P2 community for real (when you get the HW) and start doing some retro game coding on this superior microcontroller. I wish Baggers could come back to the forums as well, with all his commercial retro game coding experience. I know that he has got too much going on with the Spectrum Next to have any time over for the P2. (I have had a brief email conversation with him lately)
I don't think I've made a video (yes indeed, last video was in Febuary, WTF is time even?) since adding the sound (and it's not really very done at all, there's some SFX built in and by doing some silly key combos in the menu you can load some music (nothing I haven't posted yet)) and I kinda wanna wait with the next one until I get the weapons and enemies to a presentable state. That's gonna be a chunk of work (especially since I'll likely need to do some refactoring to get behaviors like "can only be damaged from the back / by a specific weapon type", which the current system can't really do - in the end, I think this is one of the few places where I could write myself into a corner, which I've always tried to avoid so far (nothing more annoying than running up against a hard limit...))
I can PM you a Windows build and some instructions though, if you wanna have a little look.
Everyone else can enjoy this nice little smonk effect I made a while ago:
Incidentally, if anyone wants to stalk my work ethic, I host the whole thing as a private GitLab project, so you can kinda see when I wasn't in great mood by looking at the graph on my user page. The actual amount of contributions is a bit misleading though, as sometimes I roll the work of multiple days into one big commit, sometimes I split them up into every little thing. Each issue created also counts as one contribution, even though most of them are just random TODOs.
@Wuerfel_21
I wish Baggers could come back to the forums as well, with all his commercial retro game coding experience. I know that he has got too much going on with the Spectrum Next to have any time over for the P2. (I have had a brief email conversation with him lately)
@Wuerfel_21
I'm really impressed with what you have achieved on the P1. I will try the Windows version of your game very soon!
@Coley
Nice seeing you here as well! 🙂
May I ask if Baggers "secret" project has something to do with the Next in combination with the P2?
I can neither confirm nor deny that 🙂
I'm still here lurking, still using P1 where I can. Waiting for P2 to settle before jumping in again.
(I tried but couldn't keep up with all the changes)
I'm glad you are still here too, still doing amazing things with sound!
Did anyone download all the modules in the archive I attached in the top post? My laptop got stolen and all those nice modules that I had gathered (some quite hard to find) over weeks are gone and so are that archive!
That’s terrible Johannes
Suppose there’s little chance of getting it back.
My work stuff gets backed up automatically. and offsite. I also keep a copy on both my work and home PCs. But my play stuff often resides on a separate internal HDD and only gets backed to a seperate external HDD not so often. But if I get robbed, they probably will take the external drives too as I don’t keep offsite backups for my private stuff any more. Of course I do post a lot of my prop stuff here so I can get those parts back.
Hope someone (@publison?) has saved a backup copy for you.
1. A raw sample file is a file containing just samples and no header or any other type of data. The sample format can be unsigned 8 bit, signed 8 bit, unsigned 16 bit, signed 16 bit. The 16 bit formats can also be in either big endian or little endian format. My driver can realtime mix any type of raw sample formats at the same (up to 64) time while independently playing at arbitrary frequency and amplitude. (a kind of software sampler)
2. I wouldn't recommend connecting a speaker directly to a P2 pin, even if a really high impedance speaker would produce sound without hurting the P2. Some kind of amplifier is needed between the pins and the speakers.
The sample format can be unsigned 8 bit, signed 8 bit, unsigned 16 bit, signed 16 bit.
Speaking of which, have you thought about adding support for companded samples? The quality is vastly superior to normal 8 bit samples and it's trivial to decompress.
Here's A-Law decoding in P1 ASM, lifted from tinySDDA:
'' Compressed sample in atmp1, decompressed sample ends up in sfxsample
'' Decompress A-law
xor atmp1,#$55
mov sfxsample,atmp1
and sfxsample,#$0F ' mantissa isolated
shl sfxsample,#ALAW_BASESHL
add sfxsample,alaw_bias
mov atmp2,atmp1
shr atmp2,#4
and atmp2,#7 wz ' exponent isolated
if_nz add sfxsample,alaw_leading
if_nz sub atmp2,#1
shl sfxsample,atmp2
test atmp1,#$80 wc
negnc sfxsample,sfxsample
'' ....
alaw_bias long |<(ALAW_BASESHL-1)
alaw_leading long $10<<ALAW_BASESHL
CON ALAW_BASESHL = 19 ' controls output level
This can be optimized a good bit more on P2.
Untested:
'' Compressed sample in atmp1, decompressed sample ends up in sfxsample
'' Decompress A-law
xor atmp1,#$55
getnib sfxsample,atmp1,#0 ' mantissa isolated
shl sfxsample,#ALAW_BASESHL
add sfxsample,alaw_bias
shl atmp1,#25 wc ' got sign bit
shr atmp1,#29 wz ' exponent isolated
if_nz add sfxsample,alaw_leading
if_nz sub atmp1,#1
shl sfxsample,atmp1
negnc sfxsample,sfxsample
'' ....
alaw_bias long |<(ALAW_BASESHL-1)
alaw_leading long $10<<ALAW_BASESHL
CON ALAW_BASESHL = 19 ' controls output level
Comments
But since the P2 has this continue where it left off kind of interrupt features... Maybe this isn't practical if it's not saving enough registers.
What context and registers does the P2 save during an interrupt and restore upon return?
I'm saving all cog register RAM on entry and restoring it on return. I do not use the CORDIC or the LUT. I'm pretty sure that I'm messing up something FastSpin specific. I think it is the "objptr" (FastSpins internal data pointer) that gets used before the previous add/sub sequence is finishen. That makes it point to an offset instead of the baseline.
Long time no seen!
I just wanted to post a little sound engine that can play music and sound effects at the same time. It's basically an abstraction layer for reSound + a module player in one package. It hides all complicated details about mixing frequency and configuration parameters and stuff. Just specify which smart pin numbers to use for stereo output, attach a module file and some samples and you are off.
Features:
* Is totally clock frequency agnostic and will adapt the mixing frequency accordingly while playing samples at the right rate
* Using a clock frequency of 252 MHz and a total of 12 sample channels (default), the mixing frequency is a respectable 218 kHz
* Has got 8 dedicated sample channels by default, but that can easily be changed to anything (8 is enough for most things)
* Has got 4 dedicated sample channels for music playback
* Has got a simple and easy API
* Compiles fine with both Chips interpreter and FastSpin
Enjoy!
(this object is just a stepping stone to the real sound engine I want to make... stay tuned)
/Johannes
long[inputHandle][5].[2] := true ' Disable the buffer pointer + phase accumulator calculation
' NOW let's set the new parameters
long[inputHandle][3] := loopSize << phaseAccuShift ' Loop size
long[inputHandle][2] := -bufferSizeShl ' Trigger offset
long[inputHandle][1] := samplePtr - ptrAdjustment ' Buffer pointer, non zero values starts the phase accumulation again
long[inputHandle][5].[2] := false ' Enable the buffer pointer + phase accumulator calculation again
Just uncomment those lines and it should almost work the same, just possbile some extra glitches when a sample starts playing.
Very cool stuff as usual Ahle2! I gotta get you the HyperRAM driver asap so you can work it into your playback for large mod files etc. We just need a good way to get large amounts of code/data loaded into there given the limited 512k binary size on the P2 itself. Maybe we need a modification to loadp2 or something, or a way to use the SD, though that is less convenient to have to remove/re-install each time etc.
I'm confident that it is going to be very useful for audio especially with that large 32MB area for wavetable samples in HyperFlash that can be read really quickly into HUB etc.
proploader for P1 has a feature where it can download files to the SD card over serial. It's really slow, but that has more to do with the low baudrate used. A similar thing could be made for P2. Could probably handle 3Mbaud with ease.
Should probably tag @ersmith
Fastspin is OK with bit fields on variables and simple array references, but not with the example you gave. "long[inputHandle+20].[2]" should work though. *EDIT* there's a problem with that too. With fastspin 4.3.1 you'll have to use "long[inputHandle][5] |= 4". All of the forms should be fixed in github now though.
Thanks! Yeah, I would really like to get hold of your driver to do some cool stuff. It will be very useful. You have made a tremendous lot of work on that one (as far as I understand reading the thread from time to time) and it will benefit the whole community in the end. Your video driver is ace as well. Thanks for your contributions!
@Wuerfel_21
What are you up to on the P2? I know you did some cool video drivers and even a game that sadly never got released for the P1. It all looked very promising!
@ersmith
Thanks for the fix! When will there be a new version of FastSpin that includes this? Or do I have to compile it myself?
Just backseat coding right now - don't have a P2 here yet - EU P2 shipping is apparently very expensive - and I assume the entire thing will get a bit cheaper when production silicon comes out.
Also, I'm still working on the game - it just goes slowly. Currently somewhat stuck on deciding the overall plot and structure (one of the reasons I decided to have a break in July, wherein I made Spin Hexagon (1080p P2 port when?) ), so I'm mostly doing random bits of programming (like writing a custom parser for GraphicsGale's proprietary layered file format to automate the generation of character face sets from layered files... I don't think I ever posted a video of the dialog system in action?) and drawing the odd graphic right now. Also have like 2 tunes that need converting to Retronitus format (and one that I need to revisit, I kinda got frustrated with - otoh I left like 4 more tunes worth of unfitting-yet-good bits in that file, hah)
But ah, perseverance is a virtue or smth (I'm up to 14370 non-blank,non-comment lines of .rasm files (mixed ASM and compile-time Ruby (used as "super macros" of sorts)) right now - a couple thousand more if I'd also count the native P1 code, the helper scripts, the map editor and the high-level emulator I wrote...)
Wow, you have spent a lot of time and energy on those projects! Do you have some videos of your Zelda clone in action with Retronitus sound? I never got to the point where Retronitus got incorporated into a real game, even though that was the driving force when I started working on it. I'm really looking forward to you joining the P2 community for real (when you get the HW) and start doing some retro game coding on this superior microcontroller. I wish Baggers could come back to the forums as well, with all his commercial retro game coding experience. I know that he has got too much going on with the Spectrum Next to have any time over for the P2. (I have had a brief email conversation with him lately)
I don't think I've made a video (yes indeed, last video was in Febuary, WTF is time even?) since adding the sound (and it's not really very done at all, there's some SFX built in and by doing some silly key combos in the menu you can load some music (nothing I haven't posted yet)) and I kinda wanna wait with the next one until I get the weapons and enemies to a presentable state. That's gonna be a chunk of work (especially since I'll likely need to do some refactoring to get behaviors like "can only be damaged from the back / by a specific weapon type", which the current system can't really do - in the end, I think this is one of the few places where I could write myself into a corner, which I've always tried to avoid so far (nothing more annoying than running up against a hard limit...))
I can PM you a Windows build and some instructions though, if you wanna have a little look.
Everyone else can enjoy this nice little smonk effect I made a while ago:
Incidentally, if anyone wants to stalk my work ethic, I host the whole thing as a private GitLab project, so you can kinda see when I wasn't in great mood by looking at the graph on my user page. The actual amount of contributions is a bit misleading though, as sometimes I roll the work of multiple days into one big commit, sometimes I split them up into every little thing. Each issue created also counts as one contribution, even though most of them are just random TODOs.
I wouldn't be so sure about that ;-)
I'm really impressed with what you have achieved on the P1. I will try the Windows version of your game very soon!
@Coley
Nice seeing you here as well! 🙂
May I ask if Baggers "secret" project has something to do with the Next in combination with the P2?
I can neither confirm nor deny that 🙂
I'm still here lurking, still using P1 where I can. Waiting for P2 to settle before jumping in again.
(I tried but couldn't keep up with all the changes)
I'm glad you are still here too, still doing amazing things with sound!
Thanks for the kind words... Audio coding is too fun, I will never stop doing that!
Did anyone download all the modules in the archive I attached in the top post? My laptop got stolen and all those nice modules that I had gathered (some quite hard to find) over weeks are gone and so are that archive!
/Johannes
The zip file is visible in the first post. Are there others?
Suppose there’s little chance of getting it back.
My work stuff gets backed up automatically. and offsite. I also keep a copy on both my work and home PCs. But my play stuff often resides on a separate internal HDD and only gets backed to a seperate external HDD not so often. But if I get robbed, they probably will take the external drives too as I don’t keep offsite backups for my private stuff any more. Of course I do post a lot of my prop stuff here so I can get those parts back.
Hope someone (@publison?) has saved a backup copy for you.
@rogloh
Yes, that's it! Thanks!
Most of my propeller code is backed up, so no big harm there thankfully.
1#. What type of file is a .raw file? Is that just a .wav type of file without header information?
2#. With the P2 having DACs...do you just connect the speakers directly to the designated pins? Or is a cap needed to filter out noise?
2. I wouldn't recommend connecting a speaker directly to a P2 pin, even if a really high impedance speaker would produce sound without hurting the P2. Some kind of amplifier is needed between the pins and the speakers.
Speaking of which, have you thought about adding support for companded samples? The quality is vastly superior to normal 8 bit samples and it's trivial to decompress.
Here's A-Law decoding in P1 ASM, lifted from tinySDDA: This can be optimized a good bit more on P2.
Untested:
For the amplifier setup...would an old dell monitor sound bar work?
Thanks in advance..