Topic: A New Engine? Nearly.

A pretty simple, and not quite complete 1-bit engine.

I know I've been re-inventing-the-wheel here, but I'm still quite proud of doing it from scratch.

It is a monophonic, square-wave monophonic thing - but the duty-cycle varies back and forth as it plays each note from '0-100%' quite pleasingly I think.

It's based on 8-bit 'pitch' values, and I've spent *way* too long hand-tuning it, and then working out values to get a 'lengths' for each of the different pitches of notes that are consistent.

It plays reliably just under 2 octaves (From C#).  I think ultimately I'll make a look up table of pitch values, and length multipliers so it's a bit easier to compose for without an excel spreadsheet to hand!

Post's attachments

UGLI-EngineDemo.tap 843 b, 9 downloads since 2019-11-29 

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

Re: A New Engine? Nearly.

Sounds legit, would be at home in a pre-1985 ZX game.

You don't really need to hand tune pitch values, just use any script engine to calculate them out. JS, Python, etc.

Then, if you go with composing by typing in the pitch values, you don't have to have a spreadsheet. Just make aliases, like C_2=100 (or C_2 equ 100 in some assemblers). Now you can just use note names in your db's.

Then, to save time, you can just generate both pitch values and aliases with the same script, and save a ton of time. You can do this with https://js.do/, for example. Just go there, copy/paste code below, click Run.

<script>

    //standart note table for a high octave

    NoteFreqTable=new Array( 2093.0,2217.4,2349.2,2489.0,2637.0,2793.8,2960.0,3136.0,3322.4,3520.0,3729.2,3951.0 );

    NoteNameTable=new Array("C_","Cs","D_","Ds","E_","F_","Fs","G_","Gs","A_","As","B_");
    
    //generate note to period table

    cpuClock=3500000.0;
    cpuToneLoop=200.0;    //cycles per engine loop
    div=32.0;

    for(octave=0;octave<8;++octave)
    {
        for(note=0;note<12;++note)
        {
            period=Math.floor((cpuClock/(cpuToneLoop/2.0))/(NoteFreqTable[note]/div));

            document.write(NoteNameTable[note]+octave+" equ "+period+"<br>");
        }

        div=div/2;
    }

</script>
website - 1bit music - other music - youtube - bandcamp - patreon - twitter (latest news there)

3 (edited by uglifruit 2019-11-29 18:57:33)

Re: A New Engine? Nearly.

I'll give that a go, that may well be quicker than my brutal approach (play ALL the notes from 255 - 1), then record the output, and note down the values that are closest to pitches I wanted.

I have now equ'd my pitch values in my assembler, which at least means I can do that bit slightly quicker now - I can't believe I didn't think of that!

Re: A New Engine? Nearly.

Yay, congratulations on this achievement! And welcome to the rabbit hole of 1-bit engine making big_smile

Ehh, I wish I had Shiru's advice back in the day when I started to make my own engines. Could never wrap my head around it back in the day. Just like I couldn't figure out 16-bit dividers, lol. Speaking of which, I'd say try to figure those out next. Aside from having a greater note range, it actually makes things simpler wink

Of course, if you have any questions, ask away. More than happy to help.

Re: A New Engine? Nearly.

it sounds neat! Well done!

Re: A New Engine? Nearly.

Thanks for the encouragement.
A few tweaks later, and it starts an octave lower and has a much larger useful range before the tuning (and aliasing) render it crap.

I've also introduced a "rests", which will help.

Making an Excel spreadsheet, with lots of use of Concatenate to generate copy and pastable "equ" statements for my assembler has improved things no end... And should make any music I make with it much more portable down the line, so thanks for that tip.

I'll post source code, etc, when I've reached a v1 that I'm happy with.