News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_PulkoMandy

Playing music with BASIC

Started by PulkoMandy, 10:05, 04 May 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PulkoMandy

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?

dodogildo

#1
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
M'enfin!

PulkoMandy

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...

mr_lou

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. :)

Deevee

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 ?
ORIGIN 320,200:FOR r=1 TO 360:PLOT 5*(16*(SIN(r))^3),5*(13*COS(r)-5*COS(2*r)-2*COS(3*r)-COS(4*r)):NEXT

mr_lou

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.

PulkoMandy

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). 

andycadley

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.

Deevee

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.
ORIGIN 320,200:FOR r=1 TO 360:PLOT 5*(16*(SIN(r))^3),5*(13*COS(r)-5*COS(2*r)-2*COS(3*r)-COS(4*r)):NEXT

andycadley

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).

Deevee

I wonder if we are not saying the same thing with different words ^^
ORIGIN 320,200:FOR r=1 TO 360:PLOT 5*(16*(SIN(r))^3),5*(13*COS(r)-5*COS(2*r)-2*COS(3*r)-COS(4*r)):NEXT

Powered by SMFPacks Menu Editor Mod