1 (edited by utz 2016-10-15 17:03:38)

Topic: new engine: BetaPhase

In continuation of this discussion, I wrote a new experimental engine based on Shiru's concepts. It's called BetaPhase because, uh, it's unfinished and probably will be in eternal beta status. It's intended more as a test-case rather than something you'd actually use for music production.

The engine may not sound all that impressive, it's more about the magic that's happening code-wise. Anyway, on the front end we've got 2 "simplified" Phaser channels, and one regular square wave channel with fixed 50% duty that can do slides. Phase offset is used to change the duty of the Phaser channels.

Special code features used:
- no use of duty threshold comparison trick (which was my self-set challenge for this engine), phase determines duty
- fast counter updates with 13-bit frequency resolution (bit 12 of the counter determines output state)
- and a little addition to the code discussed earlier: scalers. (zilogat0r proposed those a while back, but I think that's not quite what he meant big_smile)

   add hl,bc
   ex de,hl
   nop            ;swap with adc hl,bc for duty modulation
   add hl,bc
   ex de,hl
   ld a,h
   nop          ;pre-scaler, modified with rlca/rrca
   xor d
   nop          ;post-scaler, as above
   out (#fe),a

The prescaler can be heard on the bassline in test.tap, and briefly on the arpeggios as well. The post-scaler actually seems unnecessary, 12-bit frequency resolution is sufficient to reach low notes without detuning too much. So it might be more interesting to have two pre-scalers instead.
Also, duty modulation with adc hl,bc is very ineffective, so I might consider removing it. However, modifying it with inc bc is too fast and sounds unpleasant. Still need to find a solution for this. Also, some way to create noise would be nice. So, as I said, the engine is currently quite unfinished.

Anyway, source for the engine is here, feel free to play around with it.

Edit: Counting bits... it's hard, lol. Of course bit 12 of the counter determines the output state, not bit 11. Hence, we've actually got 13-bit frequency resolution. Better than AY wink

Post's attachments

test.tap 1.55 kb, 7 downloads since 2016-10-15 

You don't have the permssions to download the attachments of this post.

Re: new engine: BetaPhase

Good news everyone, BetaPhase is the first engine to get Music Data Abstraction Language (MDAL) support! (If you missed the discussion about MDAL, read up on it here.

I haven't written much documentation yet, but usage should be pretty straightforward. Check out docs/betaphase.txt and examples/betaphase-demo.mdal. Some general notes:

- Unlike standard music markup languages like MML or ABC, the notation in MDAL is row-based, just like you would do it in a tracker.
- If you don't want to change anything in a given row, you can use the dot command (.) to specify just that.
- Pattern names must be lowercase.
- Specifying a loop point in the sequence is optional (will be set to sequence start if not specified).

MDAL is still in very early beta stage, I'm expecting it'll have tons of bugs at this stage. Let me know if you find any.
Most notably, there are two problems at the moment:
1) Mixing of strings and bit flags is not yet supported. In case of BetaPhase, that means that upward slides cannot be used in conjunction with note names, so you'd have to supply a note divider instead (see pattern1b in betaphase-demo.mdal)
2) There's no support for global constants yet, so MDAL will fall back to internal defaults in some cases (for example, speed is reset at the beginning of every pattern)

source:

git clone https://github.com/utz82/MDAL.git

win32 build


In the meantime, I've found a way to generate noise in BetaPhase, but I haven't updated the engine yet. Stay tuned. Meanwhile, a new, crappy demo tune, produced by the MDAL converter:

Post's attachments

test.tap 3.37 kb, 5 downloads since 2016-10-19 

You don't have the permssions to download the attachments of this post.

Re: new engine: BetaPhase

Every new engine you make sounds even more amazing than the previous ones. This MDAL notation looks powerful!
I'll have a look at all this more closely tomorrow.

Re: new engine: BetaPhase

ah, and I forgot to tell, I love the borders! Best border effects so far!!

Re: new engine: BetaPhase

I've tried to compile the music.asm resulting from the mdal command (the betaphase.mdal sample), and it seems the 'include "equates.h"' is missing in the output, and I got an error:

ERROR: Symbol 'a1' is undefined

I've included myself the equates.h and it works!

Re: new engine: BetaPhase

I guess the "is" included after a note (for example fis2) is for sharp (here: f sharp)?

Re: new engine: BetaPhase

Ah, yes, I made a last minute change and probably forgot to update main.asm in the repo. Thanks for reporting, will fix asap. Edit: done.

The "-is" suffix is indeed for sharps, forgot to mention that as well. (German notation, hehe) Using an actual # char would break pasmo, so we'll have to live with "-is" I guess. Originally I had "h" instead of "b" as well yikes

Anyway, thanks for the cheers wink

Btw fancy website for MDAL: https://utz82.github.io/MDAL
Not much content in the wiki yet, will be filling that in in the coming days.

8 (edited by garvalf 2016-10-21 21:12:54)

Re: new engine: BetaPhase

ah yes, German notation... I was wondering.
Is it possible to use flat as well?

Just saying, in abc flat is _ before the note, ^ is for sharp and = for natural (but not applicable in mdal). So ^f2 would be f2 sharp and _g2 would be g2 flat.

I think you made something great with MDAL. It's perfectly suitable for this kind of music. The only criticism I could say is I find it less readable to get all the info on the same level for example:

A=a1, MIXA=xor, PHA=$800, PSCA1=down, C=c4, PSCC=down, SLIDESPD=$30, SPD=6

It might be more readable like this, with options between parenthesis:

A=a1 (MIXA=xor, PHA=$800, PSCA1=down), C=c4 (PSCC=down, SLIDESPD=$30, SPD=6)

(but maybe it's just me)

(edit)

I have a newer question. I have a simple example like this:

CONFIG=BetaPhase

:SEQUENCE
    
    ptn0
    [loop]
    ptn1
    
    

:ptn0
    A=e1, MIXA=xor, PHA=$400, PSCA1=none, PSCC=down, SLIDESPD=$30, SPD=12
    A=e2
    A=e1
    A=e2
    
:ptn1
    A=e1, MIXA=xor, PHA=$800, PSCA1=down, C=a3, PSCC=down, SLIDESPD=$30, SPD=12
    A=e2, C=rest, SLIDESPD=0
    A=e1, C=e2
    A=e1, B=f2
    A=e1, C=fis2
        A=e1, C=g2
        A=e1, C=gis2
    A=e2, C=b2

is the speed persistent across the patterns? For ptn1 if I remove SPD=12 then I get a little glitch (high pitch tone). If I set SPD=10 (default?), it's even different.
ok I understand, SPD=16 is default (and I get the sound glitch as well)
SPD=16 is 0x10

Re: new engine: BetaPhase

garvalf wrote:

ah yes, German notation... I was wondering.
Is it possible to use flat as well?

Yes. It's a matter of adjusting the equates.h file, MDAL itself doesn't care what you feed it (for now, at least).

garvalf wrote:

Just saying, in abc flat is _ before the note, ^ is for sharp and = for natural (but not applicable in mdal). So ^f2 would be f2 sharp and _g2 would be g2 flat.

Any special characters are likely to cause trouble with assemblers, unfortunately. For pasmo, ^ would be interpreted as XOR, and _xxx is a local label. For this reason, MDAL doesn't accept special chars in strings atm (it shouldn't, at least, not sure if I actually implemented that check already). On the long run, I could possibly work out a standardized pitch notation in MDAL, but for the time being it's not really feasible.

garvalf wrote:

I think you made something great with MDAL. It's perfectly suitable for this kind of music. The only criticism I could say is I find it less readable to get all the info on the same level for example:

A=a1, MIXA=xor, PHA=$800, PSCA1=down, C=c4, PSCC=down, SLIDESPD=$30, SPD=6

It might be more readable like this, with options between parenthesis:

A=a1 (MIXA=xor, PHA=$800, PSCA1=down), C=c4 (PSCC=down, SLIDESPD=$30, SPD=6)

(but maybe it's just me)

Good idea, and it should be fairly simple to add. Perhaps I'll do
A=a1, (MIXA=xor, PHA=$800, PSCA1=down), C=c4, (PSCC=down, SLIDESPD=$30, SPD=6)
though, then I can just simply strip out the brackets when parsing (and usage of the brackets would be optional).

garvalf wrote:

is the speed persistent across the patterns? For ptn1 if I remove SPD=12 then I get a little glitch (high pitch tone). If I set SPD=10 (default?), it's even different.
ok I understand, SPD=16 is default (and I get the sound glitch as well)
SPD=16 is 0x10

Probably a bug in the compiler. I'll have a look in the coming days. In theory, all values should fall back to their defaults at the beginning of a pattern ($10 for speed in this case). Btw I pushed a new commit a couple of hours ago where I changed some things related to this mechanism, do you have that already? (Simple check: if /config/BetaPhase.cfg has an INIT_DEFAULTS command in the CFG_PATTERNS block, you've got the latest version.

10 (edited by garvalf 2016-10-22 08:08:15)

Re: new engine: BetaPhase

It works quite good.
I've begun to convert a little jig I made for gameboy (see attachment). Nothing fancy, it doesn't sound really "advanced" like the demo tunes. It made me work with the MDAL language though.

I see you're looking for making some global constants, it will be a great thing.

I'll post more about this soon.

Post's attachments

jig.tap 1.45 kb, 3 downloads since 2016-10-22 

You don't have the permssions to download the attachments of this post.

11

Re: new engine: BetaPhase

Nice little tune wink And glad to see that MDAL doesn't break immediately when other people use it big_smile

In other news, structuring with brackets in patterns is now possible. Just don't skip any of the commas, like I wrote above.
Also I believe I know where that glitch is coming from. Slides in BetaPhase don't stop when they reach the limit. So since the speed is falling back to $10 at the beginning of ptn1, the slide wraps to $ffxx and that's what's causing the glitch. Can't do much about that yikes

12 (edited by garvalf 2016-10-22 12:04:34)

Re: new engine: BetaPhase

A little feedback.

First,
I think the parser could be less strict, for example you can't write:

A=a3, C=d2,

the last comma prevents to compile the song.
As long as there is no data except space, tab or line break, it could consider the comma doesn't exist.

I'd like to see a comment mark (for example to comment a part so it won't play during the rendering)


I like the idea of columns for entering notes. I has an interesting effect, you don't have to enter the value of some notes, like that:

A=g3, B=d2
    A=d3
    A=a3
    A=f3
    A=e3
    A=g3
    
    A=f3, B=c1
    A=d3
    A=e3

here we have for B the d2 note which will last 6 steps, then c1 will last 3 steps. Yeah, basically it's the same as in trackers smile
I guess also it's easier to parse the notes.


It has some drawbacks however: It's less easy to copy and paste a track (for example channel 2). Some text editors support vertical selection though. When a channel is on a line, you can duplicate it more easily.
I think in addition to the current behaviour, it might worth adding, if possible, independent patterns, it means a pattern could contain only one voice, then you would mix the patterns together for different variations. The current behaviour is like on milkytracker, beepola or vortex tracker, I was thinking to something like on sidwizard or goattracker.

It means something like that would be legit:

     ptn1a, ptn1b, ptn1c

:ptn1a
A=f3, MIXA=and, MIXB=and, PHA=0, PSCA1=none, PSCC=none, SLIDESPD=0, DMOD=off, SPD=8
    A=d3,
    A=a3,
    A=d3
    A=f3, 
    A=e3, 
    
    A=f3,

:ptn1b
     B=d2,
    .
        .
        .
        .
    
     B=f2,


:ptn1c
     C=d2
     C=a2
    C=d2
    C=a2 
     C=d2
     C=a2
    
    C=c2

instead of:

    ptn1


:ptn1
    A=f3, B=d2, C=d2, MIXA=and, MIXB=and, PHA=0, PSCA1=none, PSCC=none, SLIDESPD=0, DMOD=off, SPD=8
    A=d3, C=a2
    A=a3, C=d2
    A=d3, C=a2 
    A=f3, C=d2
    A=e3, C=a2
    
    A=f3, B=f2, C=c2

It might look more verbose, but it could help to design very repetive parts. But maybe it'd be too complicated to parse.

(edit) thanks for the brackets addition, I'll have a look at it. Also for the value, what is correct, PHA=$800 or PHA=800, or is it the same?

I don't understand all the pattern commands effects, but I'll have a try.
In the betaphase.txt it's written
MIXB            Set mixing mode channel 1

I guess it's:
MIXB            Set mixing mode channel 2

13

Re: new engine: BetaPhase

Thanks for your input mate, always appreciated!

garvalf wrote:

A little feedback.

First,
I think the parser could be less strict, for example you can't write:

A=a3, C=d2,

the last comma prevents to compile the song.
As long as there is no data except space, tab or line break, it could consider the comma doesn't exist.

I'll have to think about that. It would require some rather big changes to the compiler atm.

garvalf wrote:

I'd like to see a comment mark (for example to comment a part so it won't play during the rendering)

Single line comment is // wink
I'll put block comments on the to-do list.


garvalf wrote:

I like the idea of columns for entering notes. I has an interesting effect, you don't have to enter the value of some notes, like that:

You can totally do that, mdalc doesn't care about formatting except for line breaks.

garvalf wrote:

I think in addition to the current behaviour, it might worth adding, if possible, independent patterns, it means a pattern could contain only one voice, then you would mix the patterns together for different variations. The current behaviour is like on milkytracker, beepola or vortex tracker, I was thinking to something like on sidwizard or goattracker.

I definately plan to implement this, as there are some beeper engines that actually require data in this format (zx16, for example). However, it'll be a while before I get around to this. First, I want to finish preliminary documentation, clean up the code, and implement tables.

garvalf wrote:

(edit) thanks for the brackets addition, I'll have a look at it. Also for the value, what is correct, PHA=$800 or PHA=800, or is it the same?

With $ prefix, it's a hex number wink so PHA=$800 == PHA=2048

garvalf wrote:

I don't understand all the pattern commands effects, but I'll have a try.
In the betaphase.txt it's written
MIXB            Set mixing mode channel 1

I guess it's:
MIXB            Set mixing mode channel 2

Ah yes, of course. Well spotted wink

14 (edited by garvalf 2016-10-22 14:35:31)

Re: new engine: BetaPhase

don't bother with the , suggestion. It's sometimes quicker to keep them in place when you just remove an item, but it probably doesn't worth too much work on this.

For the comments, I can't use // in front of a pattern list (in the "sequence" part), I got this:

ERROR: Pattern "//    ptn1" is not defined.

I'm glad you've already considered using multiple patterns, it's not in a hurry but it'd help for song design. I think the mdal format would be more complete this way smile

15

Re: new engine: BetaPhase

Ok, noted the problem with the comments in sequence. The current pattern parser needs some reworking anyway, so I'll fix this problem when I get around to that. I'll think about the comma thing too, it'll require some extra code but can't hurt to make the parser more robust in this respect.

Since you were wondering, I'll try to give a better explanation of what the effect settings do.

The basic thing you have to understand is that the first two channels each use two semi-independant oscillators. Semi-independant because they share the same frequency divider ("A" resp. "B"). The output of the two oscillators is combined using the MIXA resp. MIXB method. This works the same way as in Shiru's Phaser engines (namely Phaser2/3, Phaser1 has only XOR mixing).

Before the mixing, a pre-scaler is applied to the first oscillator (PSCA1/PSCB1). This prescaler will shift output from the first osc up or down by one octave. After mixing, a post-scaler is applied to the combined output (PSCA2/PSCB2), which again shifts one octave up or down. This feature will probably be removed in favour of a second pre-scaler in the next version, because it's not really necessary (I was originally afraid that tone range would be insufficient, but that seems to be not the case).

On channel 1, there's also the duty modulator (DMOD), which should theoretically do what the "Duty Sweep" effect in HT2 ch2 does. However, the implementation is so slow that the effect is barely noticable - I'll probably replace it with something better in the next version as well.

Last but not least, there's the phase offset (PHA/PHB). The value you enter here is used to initialize the second oscillator before the sound loop (the first osc is always initialized to 0). If you don't use the pre-scaler and set MIXx=xor, this will essentially act as a duty setting (4xx/5xx/6xx in HT2). Setting PHx to $1000 will give a 50:50 square wave, $800 would give 25:75. There's no point in using values >$1000 unless you have PSCx2 set to "down" - in this case, $2000 will give 50:50 duty. Likewise, if PSCx2 is set to "up", $800 will be the max.

Channel 3 on the other hand has only one oscillator. PSCC is a post-scaler. Here, post-scaling makes sense because it has an effect on slide speed.

Hope that makes sense wink

16

Re: new engine: BetaPhase

Little sneak preview of the next version on BetaPhase attached below.

Changes:
+ Ch1/2 post-scalers are now pre-scalers
- Old (slow) Ch1 duty mod removed
+ New Ch1 duty mod, can be heard in the intro (using osc sync method - runs a bit too fast for my taste, so it's not terribly useful in any case)
+ Ch1 noise support
+ Ch2 duty mod w/ custom sweep speed, can be heard in the interlude (using Shiru's implementation, but with a variable counter increase every 256 loops instead of constant increase every loop)

Post's attachments

test.tap 2.06 kb, 5 downloads since 2016-10-24 

You don't have the permssions to download the attachments of this post.

Re: new engine: BetaPhase

thanks for the explanations. And the new features sounds really cool! Now it'll be super easy to make ambient music on the spectrum!

18

Re: new engine: BetaPhase

Updated BetaPhase on github, and also updated the MDAL config accordingly.
If you want to keep using the old version, just rename the old BetaPhase.cfg to something like BetaPhaseOld.cfg, and use that name for the CONFIG= command. Generally speaking though, MDAL modules made for BetaPhase 0.1 should be mostly compatible with the new 0.2, except for the following:
- DMOD is now called DMOD1 (because there's also a DMOD2 command now)
- PSCA2/PSCB2 are now pre-scalers

A special note about the new NOISE command - the current implementation is a bit awkward. Basically, when you enable NOISE, you must also set PSCA1=0 and PSCA2=0. Likewise, when disabling noise, you should set PSCA1/2 to a value of your choice. You might as well ignore the noise command and just set PSCA1=$cb and PSCA2=2. The problem exists because I didn't forsee this particular use case where an internal masking command (SET_IF) should overwrite an existing value rather than ORing to it. I'll need to implement another config flag to avoid this mess but this might take a while.

19

Re: new engine: BetaPhase

Made quite some progress on the back end today. There's also a couple of front end changes:

- The [loop] command is now [LOOP], for consistency since all commands are uppercase in MDAL.
- // comments should now work everywhere.
- Block comments (/* ... */) are now available.

Re: new engine: BetaPhase

That's cool. It's easier to design songs now there is this comment system. Thanks.
I find it still a bit difficult to compose something without listening to it while I'm entering notes but I think it could be a good exercice to train my ear. I can also design some melodies in a tracker if needed.

21

Re: new engine: BetaPhase

I'm also still very much intending to add XM import at some point, though there are more, uh, pressing problems at the moment wink