Last year I said it would "get finished one of the following weeks"... And now I'm having finals, so I need something to procrastinate on. I've run out of YouTube videos to watch... so, update! I actually did this a few months ago already, so if you've talked to me you probably already know about it, but it didn't have a forum topic yet.

Compared to the proof-of-concept in https://ceme.tech/t16707, I completely rewrote all of it (which is also why I think it's alright that I'm making a new topic for it). This is what it sounds like:


(well, that's what it sounded like a few months ago, but I haven't done much since then)
Note that:
  • There is a whole 5th channel being mixed in that is just muted.
  • Notice all the fancy effects! Vibrato, pwm and such...
  • The player in the video is 2.5 KB or so. The song data is another 1.5 KB (although, because it is a canon, it only needs to store the main theme once, and the three channels can play from different points of the same data).
  • At 1:25 it turns stereo. Here the left and right channels were recorded on separate runs because the computer I was using at the time only had a single audio input channel.


The current thing I'm working on is drums (which is that one muted 5th channel). It seems pretty promising. It's already pretty much finished, I'm just trying to create "samples" at this point (which are not really samples, hence the quotes). Please remind me to post an update in a few days. A farther-off goal is turning this into a rhythm game! Because we don't have any of those yet.

Also, source code on github! And here is the 8xp for the song in the video (press ENTER to start playing, press ON to stop playing, press ON while it isn't playing to quit).

I'm also planning to do a series of writeups (or videos) about how exactly the sound engine works.
Nice work! Havn't seen many multi-channel sound programs like this one(SDTQ Player is the only one I know), and the vibrato effect is amazing! Can't wait for a Piano-Tile-like game for the 83+/84+ series Razz
Update! I tried making something with drums.
a.ogg (EDIT: see post below for update)
The drums aren't that good. There's probably some bug that causes them to act weirdly that I need to figure out. I didn't add any of the fancy effects from the previous one yet. Vibrato is bugged, even. I also tried to use the bass channel but it wouldn't play anything at all. Another bug. Oh well, problems for later. Enjoy this in the meantime.

(by the way, I'm using an arpeggio there (the rapidly alternating notes in the main theme) because I ran out of general-purpose channels, but if I can manage to engage the bass channel that should be solved)
(also, you can probably hear that the high notes in the countermelody don't sound very good... those are aliasing artifacts because it runs at a sample rate of about 18 kHz)

I also made a fasmg include file that allows you to write songs in a more user-friendly format:


I should also update the repo but at this point I've made so many commits without keeping track of them... I'll do something about it eventually.
Wow cool choice of song! I like the user friendly format, that is great.

Now we just need a sndcard for the CE too Smile.
How does this work? Does the sound come out of the calculator itself, or do you plug in a sound output device? I was thinking about this a while ago, and came up with a seviceable idea for pumping 64bit sound out of the serial port, but didn't get around to asking people how the heck the sound worked. Would that work?
sJRw wrote:
How does this work? Does the sound come out of the calculator itself, or do you plug in a sound output device? I was thinking about this a while ago, and came up with a seviceable idea for pumping 64bit sound out of the serial port, but didn't get around to asking people how the heck the sound worked. Would that work?


Monochrome calcs (and the CSE, which, because I'm not doing anything LCD-related for now, this can actually run on) all have a serial port (DBUS, linkport, I/O, whatever you want to call it). (well, last year, TI stopped putting them on the 84+ (which is extremely lame))
Anyway, this is actually a 2.5mm TRS jack. Which is just a smaller version of your regular 3.5mm stereo audio jack. You can buy adapter cables to convert between these (and even headphones that specifically plug into a 2.5mm port). Some devices that need to be small use these ports for actual audio output (like some MP3 players, some bluetooth headphones that support plugging in a cable, and probably more).

So now, if I want to play an 440 Hz tone through this port, I need to toggle it between 0 and 1, 440 times per second (or well, 880, one for up and one for down). I also need to make sure the timing is exactly right, because otherwise you get out-of-tune notes (or, if the way in which it is wrong is irregular, noise).
Also, using this method, you can only play one note at a time. There are ways of outputting more notes at the same time (which is what I'm doing here) but it means I need to output to the port at almost 100 kHz... every 176 clock cycles to be exact (which is really really tight for a Z80).

Anyway... here is an update of the zelda theme I shared last post: untitled.ogg
This sounds very good for a calculator!

Also if for whatever reason someone cannot get their hands on a 2.5mm adapter for their headphones then you can just put an AM radio close to your calculator or put the calculator next to an electric guitar's pickups and then you'll hear the calculator sound through the AM radio or guitar amplifier.
I finished the Zelda theme now. Here's a youtube video:


I also just pushed the changes to the repo. Run fasmg songs/zelda_4swords/zelda_4swords.{asm,bin} and fasmg test/test_zelda.z80 to generate the 8xp to play this. I also added some more instructions to the readme on what you can assemble if you want to experiment.
It would definitively be cool if this could be used inside simple games (preferably no scrolling, bullet-hell and stuff like that). Would allowing processing power for game stuff require removing one channel entirely?
DJ Omnimaga wrote:
It would definitively be cool if this could be used inside simple games (preferably no scrolling, bullet-hell and stuff like that). Would allowing processing power for game stuff require removing one channel entirely?


There is certainly some processing time left over, although the exact amount depends on clock speed. My estimate is a few ten thousand clock cycles per "frame" (1/50th second). This is way too little for most things. Displaying anything on the screen is likely to take longer than that. Deleting one channel would add another 50k cycles per frame, and actually I've already been thinking about doing that... But I want to see if it's possible with all channels first.

Scrolling is actually possible if it's vertical because it can be hardware accelerated (which for some reason no one seems to bother with using). It could be possible to create a rhythm game by only updating a single row of the screen at a time and using this function to scroll everything. Which I have planned to do eventually. One problem with this approach is that you can't have an overlay with a score counter, for example, as that would also get scrolled. Unless you were to overwrite this score counter on every frame too.

Note that the entire game would have to be written around the sound engine, you can't just slot it into an existing game and expect it to work. It doesn't just "run in the background". But it also doesn't just run in the foreground. It uses both, which means the game logic can neither use interrupts, nor have a continuous execution state (which isn't really a problem is assembly tbh). It also uses a really weird memory layout and cannot depend on any OS routines whatsoever. All of this can be worked around, but it's probably not worth it for most games to spend 97% of their processing time doing this sound gimmick anyway (unless it's a major part of the game experience, like in rhythm games).
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement