CPCWiki forum

General Category => Programming => Topic started by: PulkoMandy on 10:05, 04 May 24

Title: Playing music with BASIC
Post by: PulkoMandy on 10:05, 04 May 24
Hello,

So, I may be working on a BASIC demo for a possible BASIC demo context in an upcoming demoparty.

Of course, no assembler code is allowed. Which means if I want to play music, I have to do it in BASIC as well.

I think such things exist in some old CPC games, but are there tools to do it? Or am I completely on my own entering endless lists of DATA statements with note frequencies and durations?
Title: Re: Playing music with BASIC
Post by: dodogildo on 11:49, 04 May 24
https://archive.org/details/amstrad-cent-pour-cent-25-1990-04acme/page/55/mode/1up?view=theater

Amsdreus a score-writing utility in BASIC. Published in french Amstrad CPC magazine #25-#27
Title: Re: Playing music with BASIC
Post by: PulkoMandy on 13:56, 06 May 24
This doesn't seem to have a simple way to replay the musics in my own BASIC listing. I was expecting something that would export ENV, ENT and SOUND commands that I could integrate in my own code. Maybe it's possible to extract the player from the editor BASIC listing but that doesn't look very fun.

Well, it's an option if nothing else exists...
Title: Re: Playing music with BASIC
Post by: mr_lou on 14:17, 06 May 24
I'd actually thought about making a MOD->Amstrad CPC BASIC converter after my MOD->AKS1 converter.
But lost the interest again.
Nice to see someone else caring about BASIC though. :)
Title: Re: Playing music with BASIC
Post by: Deevee on 14:46, 06 May 24
That's something I don't really need any more, but that can be fun to work on nevertheless. Do you have a song already you want to play ?
Title: Re: Playing music with BASIC
Post by: mr_lou on 14:51, 06 May 24
Have a look at an old abandoned BASIC project of mine:
https://www.cpcwiki.eu/forum/programming/abandoned-basic-game-project

I vaguely recall putting something "clever" in there, instead of "endless DATA lines".
But you'll have to grasp what I'm doing before you see how clever it is.
Basically, I'm using a "keyboard" string (QWERTYUI) for tones instead of inputting frequencies.
Title: Re: Playing music with BASIC
Post by: PulkoMandy on 15:07, 06 May 24
Quote from: Deevee on 14:46, 06 May 24That's something I don't really need any more, but that can be fun to work on nevertheless. Do you have a song already you want to play ?
No, I guess the song will be done depending on the limitations of the player. I don't expect to have the full flexibility of the usual tools, especially if I want some other things to also be working (my main effect does not need a lot of computing, but it needs to run every frame or maybe every 2 frames to do some CRTC register tricks). 
Title: Re: Playing music with BASIC
Post by: andycadley on 15:35, 06 May 24
Quote from: PulkoMandy on 15:07, 06 May 24
Quote from: Deevee on 14:46, 06 May 24That's something I don't really need any more, but that can be fun to work on nevertheless. Do you have a song already you want to play ?
No, I guess the song will be done depending on the limitations of the player. I don't expect to have the full flexibility of the usual tools, especially if I want some other things to also be working (my main effect does not need a lot of computing, but it needs to run every frame or maybe every 2 frames to do some CRTC register tricks).
A BASIC interrupt driven music player (using ON SQ) shouldn't actually have that much impact since it queues up notes and handles then in assembly anyway (so doesn't need to respond too precisely). Structuring data to be read is probably the trickier part, DATA statements aren't great since you can only READ them sequentially and that doesn't fit well with music structure. Probably would need to be a bunch of arrays.
Title: Re: Playing music with BASIC
Post by: Deevee on 16:05, 06 May 24
I'm trying to put together something via Arkos RAW format. Idk how much time it wil take (probably a couple of days).
Quote from: andycadley on 15:35, 06 May 24A BASIC interrupt driven music player (using ON SQ) shouldn't actually have that much impact since it queues up notes and handles then in assembly anyway (so doesn't need to respond too precisely). Structuring data to be read is probably the trickier part, DATA statements aren't great since you can only READ them sequentially and that doesn't fit well with music structure. Probably would need to be a bunch of arrays.

Sequenciality of the music is not the main issue I see to the usage of DATA statements. There are workarounds to that.
The biggest problem would be if the main program get interurpted by the player while reading DATA itself, I think.
Title: Re: Playing music with BASIC
Post by: andycadley on 16:08, 06 May 24
Quote from: Deevee on 16:05, 06 May 24Seuquenciality of the music is not the main issue I see to the usage of DATA statements. There are workarounds to that.
The biggest problem would be if the main program get interurpted by the player while reading DATA itself, I think.

BASIC will do all of that for you, generating a call into the relevant ON SQ for you as required to fill queues up. The tricky bit is you don't really know when each will occur, which is why the DATA being sequential can be awkward (unless you read them all into arrays initially anyway).
Title: Re: Playing music with BASIC
Post by: Deevee on 19:43, 06 May 24
I wonder if we are not saying the same thing with different words ^^
Powered by SMFPacks Menu Editor Mod