reSound - A sound driver and mixer for the P2

124»

Comments

  • On other processors, the ISR saves the registers (yes speed, complexity and memory cost).

    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?
  • 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.
  • @Ahle2 : I notice that the FCACHE loading code is using the pa register. Are you saving that register along with ptra?
  • Ahle2Ahle2 Posts: 1,072
    edited 2020-09-18 - 16:43:54
    Hi all,

    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! :smiley:

    (this object is just a stepping stone to the real sound engine I want to make... stay tuned)

    /Johannes
  • Just trying it but hit a problem with Fastspin not liking these two lines...
    Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2020 Total Spectrum Software Inc.
    Version 4.3.1 Compiled on: Sep  1 2020
    example_simpleGameSound.spin2
    |-simpleSound.spin2
    |-|-reSound.spin2
    /Users/roger/Downloads/simpleSound/reSound.spin2:295: error: syntax error, unexpected '.'
    /Users/roger/Downloads/simpleSound/reSound.spin2:301: error: syntax error, unexpected '.'
    

    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
  • 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.
  • roglohrogloh Posts: 2,777
    edited 2020-09-18 - 11:43:15
    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! :smiley: 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.
  • Wuerfel_21Wuerfel_21 Posts: 928
    edited 2020-09-18 - 11:45:02
    rogloh wrote: »
    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.
  • Ahle2 wrote: »
    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.

    Should probably tag @ersmith
  • ersmithersmith Posts: 4,429
    edited 2020-09-18 - 15:55:09
    Ahle2 wrote: »
    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! :smiley: 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_21Wuerfel_21 Posts: 928
    edited 2020-09-21 - 20:35:25
    Ahle2 wrote: »
    @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...)
  • @Wuerfel_21

    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)
  • Ahle2 wrote: »
    @Wuerfel_21

    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:
    smonk_lfo.gif

    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.

  • Ahle2 wrote: »
    @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)

    I wouldn't be so sure about that ;-)
  • Ahle2Ahle2 Posts: 1,072
    edited 2020-09-24 - 09:12:59
    @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?
  • Ahle2 wrote: »
    @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!
  • Ahle2Ahle2 Posts: 1,072
    edited 2020-09-25 - 16:43:44
    The P2 has settled, the die is cast :wink: (as in the silicon wafers will not change from now on, got the joke?! :smiley: )

    Thanks for the kind words... Audio coding is too fun, I will never stop doing that!
  • Hi,

    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
  • PublisonPublison Posts: 11,735
    edited 2020-10-13 - 21:14:25
    Are these the ones?

    The zip file is visible in the first post. Are there others?
  • Cluso99Cluso99 Posts: 16,676
    edited 2020-10-13 - 19:56:40
    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.
  • roglohrogloh Posts: 2,777
    edited 2020-10-13 - 23:23:09
    @Ahle2 Is this the list of files you need? If so and you don't already have them by now let me know.
    2_unlimited_megamix.mod       Rainbow.mod                   chinagroove.mod               help_tha_fool.mod             pinball_illusions.mod
    Acidjazzedevening.mod         Resonance2.mod                cmplctns.mod                  house_my_kolsch_up.mod        ploughman.mod
    AlphaOmega.mod                STARDUST_MEMORIES.mod         cold_as_charity.mod           hwired.mod                    posisions.mod
    Amore.mod                     Signia.mod                    cthrag_yaska.mod              jagfunk.mod                   progressive-funk.mod
    Andromeda-nexus_7.mod         Skid_Row4.mod                 ctrix_-_demodiscoparty.mod    jagtitle.mod                  project-x.mod
    BLOODM.MOD                    Starworx.mod                  ctrix_-_syntax2010.mod        kingsofdawn.mod               rallye.mod
    Breathless.mod                Subway3.mod                   deegroovie.mod                kinky_socks.mod               s_h_e_n_a_n_d_o_a_h.mod
    Coloris.mod                   Testlast.mod                  deelicious.mod                laidback4.mod                 shenandoah-title.mod
    CondomCorruption.mod          Tranzeseven.mod               deelite_-_after_midnight.mod  lightofday.mod                silkworm.mod
    D_O_S-BEGIN.MOD               Wasteland.mod                 deelitement.mod               lotus2-title.mod              sll3.mod
    D_O_S-END.MOD                 WorldOfInsanity.mod           defloration.mod               love_simulator.mod            snorewalk.mod
    D_O_S-INTRO.MOD               a-team.mod                    diskfiller_bad.mod            lvnnsnty.mod                  soundbox.mod
    D_O_S-MAIN.MOD                a_long_way_up.mod             doggysnack.mod                mailman.mod                   speed-e-boy.mod
    DejaVu-1.mod                  after_midnight_v2.mod         double_dragon_ii.mod          man_from_mars.mod             speed-storm.mod
    DejaVu-2.mod                  agony_forest.mod              dune_ecolove.mod              megademo_tune_v2.mod          static-coma.mod
    Elekfunk.mod                  agony_intro.mod               dune_fremens.mod              mini-groove.mod               still_floating.mod
    GSLINGER.MOD                  amegas.mod                    dune_wormsign.mod             mod.blood thirsty             switchback.mod
    Heimintr.mod                  axel_f.mod                    el_mariachi.mod               moodybreeze.mod               swiv-title.mod
    INTERFERENCE.MOD              background_noises.mod         elvira_catacombs.mod          mothergoose.mod               test.mod
    Ice-heart.mod                 banana_split.mod              enigma.mod                    nearly_there.mod              testmusic1_dte.mod
    Inspirationisnone.mod         beast-in_castle.mod           family.mod                    nemesis.mod                   the_spell_of_a_bard.mod
    JUMP_4_JOY_(NOW!).MOD         beast-title.mod               first_impression.mod          odyssey1.mod                  tits_that_fits.mod
    Joyride.mod                   beast2-level2-1.mod           flash7.mod                    odyssey2.mod                  touch_the_screen.mod
    Macrocosm.mod                 beast2-level2-3.mod           fooling_around.mod            odyssey3.mod                  troubled-journey.mod
    Morethanmusic.mod             beast2_1.mod                  funks_a_religion.mod          odyssey4.mod                  uralvolga-fine.mod
    Overture.mod                  beast3-death.mod              gamelevel_hurry.mod           odyssey5.mod                  worldmap.mod
    Paradox15.mod                 beyond_imagination.mod        gcomp.mod                     odyssey6.mod                  xenon2.mod
    Purple-shades.mod             beyond_music.mod              gods.mod                      overload.mod                  yuppydog.mod
    RSI-MD_SPACE-2.MOD            blood_money.mod               gtrash3f.mod                  overload2.mod
    
  • Thanks Cluso99, Publison and rogloh for willingnes to help out! 🙂

    @rogloh
    Yes, that's it! Thanks!

    Most of my propeller code is backed up, so no big harm there thankfully.

Sign In or Register to comment.