Jump to content

Photo

Procedural music in bB

music

5 replies to this topic

#1 bjbest60 OFFLINE  

bjbest60

    Chopper Commander

  • 109 posts
  • Location:Space Cactus Canyon

Posted Tue Dec 18, 2018 2:00 PM

Well, "music" might be a strong term.  "Sufficiently harmonious tones" might be better.

 

Attached is a .bin and .bas file of a program that generates, well, sufficiently harmonious tones in the key of A major.  It's fairly compact and efficient.  I've tried to include a lot of comments.  I thought I might use it in a game, but it doesn't really suit the project.  I'm posting it here in case it might benefit someone else.

 

Basically it picks a random bass note and a random melody note and plays them.  It keeps track of note length and plays things in correct time.  (The bass moves in quarter notes, the melody moves in eighth notes, with some variations possible.)  It's very basic but could be built out for more interesting (and perhaps musical) results.

 

I'm happy to answer any questions.  Enjoy!

Attached Files



#2 Muddyfunster OFFLINE  

Muddyfunster

    Chopper Commander

  • 227 posts

Posted Tue Dec 18, 2018 2:51 PM

That's actually quite neat, thanks for sharing this. Sound production is one place I really struggle in bB.



#3 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,811 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue Dec 18, 2018 9:08 PM

Is it possible to make something similar for a single channel so the other channel can be used for sound effects? If so, I could make an adapted example program for the bB page.



#4 bjbest60 OFFLINE  

bjbest60

    Chopper Commander

  • Topic Starter
  • 109 posts
  • Location:Space Cactus Canyon

Posted Wed Dec 19, 2018 10:23 AM

Is it possible to make something similar for a single channel so the other channel can be used for sound effects? If so, I could make an adapted example program for the bB page.

 

I'm not quite sure how a single channel would work ... you need two separate notes to create a harmony.  You might be able to "flicker" the music on one channel (one frame is bass, the next is melody, the next is bass, etc.) though I imagine that might sound choppy.  A better strategy might be to always have both channels doing what they're currently doing and then have a sound effect override a particular channel for a set period of time.  I'll experiment a bit when I have some time.

 

EDIT:  I tried the "flicker" effect just to hear what it sounds like.  To me, it sounds like a very insistent ringing telephone, but maybe it would be useful for the right project?  Both one-frame (that is, the sound changes every frame; this uses one bit of a variable) and two-frame (which requires a variable that can count to three) examples are attached.

Attached Files


Edited by bjbest60, Wed Dec 19, 2018 10:37 AM.


#5 Muddyfunster OFFLINE  

Muddyfunster

    Chopper Commander

  • 227 posts

Posted Wed Dec 19, 2018 4:21 PM

the 1 channel stuff sounds kind of like early ZX Spectrum music (the 48k beeper variety)



#6 Gemintronic ONLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 9,290 posts

Posted Sun Dec 23, 2018 8:11 AM

I could see two options:

 

A. Interleave two notes on one sound channel.  

 

B. Make the sound engine interrupt playback on one channel and play back a sound effect on it. 

 

I don't mind blippy simulated stereo as I grew up on Apple IIs and IBM PCs :)







Also tagged with one or more of these keywords: music

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users