My first program on HP-50g - Music. - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: My first program on HP-50g - Music. (/thread-17059.html) |
My first program on HP-50g - Music. - matalog - 06-05-2021 07:00 PM I have recently taken a liking to programmable calculators, as I use a calculator a lot in work, and like a little bit of programming. I got myself a 50g a few days ago. I must admit, that I am not taking very well or easily to the RPL way of programming, for example, I find the HP Prime language much more understandable, and usually use calculators in algebraic mode. I wrote a little program, in RPN mode here, that takes the values of a list and uses them as frequencies in a series of BEEPs. https://www.dropbox.com/s/6otu2jw4m7gjz0q/20210605_194926.mp4?dl=0 I'm sure it has been done before, but this is my first attempt at any program on the 50g, and although it is frustrating getting used to the calculator and language, it can BEEP! RE: My first program on HP-50g - Music. - Eric Rechlin - 06-05-2021 09:54 PM That is by far the most impressive User RPL music program I have heard on the 48/49/50. It almost has the polyphonic sound of some of the assembly language programs I've seen to do it. Congratulations on your first program being so amazing! Any chance you might be willing to share the code? RE: My first program on HP-50g - Music. - compsystems - 06-06-2021 06:49 AM Hello If you rewrite the firmware to NewRPL you could have a much more powerful RPL language newRPL: https://sourceforge.net/projects/newrpl/ RE: My first program on HP-50g - Music. - Stevetuc - 06-06-2021 07:02 AM (06-06-2021 06:49 AM)compsystems Wrote: Hello I'm curious as to how that improves the music program that's the topic of this thread? Edit: did the 3 channel fm synth code mentioned by Claudio here make it to newrpl? https://www.hpmuseum.org/forum/thread-9700-post-98718.html#pid98718 (06-04-2018 03:36 PM)Claudio L. Wrote: Alarms are not buggy at all, but the buzzer doesn't have a driver yet... so it's a very quiet alarm for the time being. The good new is... I found my 3-channel FM-synthesizer code, as soon as I get some spare time I'll try to port it to newRPL so it will sound much better than the usual "beep". RE: My first program on HP-50g - Music. - matalog - 06-06-2021 05:56 PM (06-05-2021 09:54 PM)Eric Rechlin Wrote: That is by far the most impressive User RPL music program I have heard on the 48/49/50. It almost has the polyphonic sound of some of the assembly language programs I've seen to do it. It's really as simple as it could be, the notes are all one length because of how the tune is written. Code: « RE: My first program on HP-50g - Music. - Joe Horn - 06-07-2021 12:11 PM (06-06-2021 05:56 PM)matalog Wrote: It's really as simple as it could be, the notes are all one length because of how the tune is written. Just a thought: In that case, the program might play smoother if you omit the inner loop, since the 50g supports list processing. Also, none of the variables are needed. Omit the 1 'N' STO, and replace everything after the end of the list with the following: 1 10 START DUP 0.08 BEEP NEXT DROP » RE: My first program on HP-50g - Music. - BINUBALL - 06-07-2021 01:09 PM (06-06-2021 06:49 AM)compsystems Wrote: HelloIs there a BEEP command on newRPL? RE: My first program on HP-50g - Music. - compsystems - 06-07-2021 03:24 PM On BEEP CMD, I don't think NewRPL team have done it yet, hopefully in an upcoming firmware release. RE: My first program on HP-50g - Music. - matalog - 06-07-2021 09:29 PM (06-07-2021 12:11 PM)Joe Horn Wrote:(06-06-2021 05:56 PM)matalog Wrote: It's really as simple as it could be, the notes are all one length because of how the tune is written. That makes it run quite a bit faster, it's now better to change the note length to 0.1 to slow it down a little. I guess it will leave less time between beeps, which has to help. Thanks for sharing that trick. RE: My first program on HP-50g - Music. - CMarangon - 06-08-2021 01:06 AM Hello! In HP48 I used to do something like store all notes in vars and so recall it from a program. I think that it also works in HP50. I store all notes as a var, so recall it from a main program. For example: <<440 .1 BEEP>> STO it in the var "LA" and do the same for "Re", "Mi", "Fa", "Sol", "La", "Si", sharp, flat and so on. Exemple of the main program: <<LA DO DO RE MI FA FA SOL SOL SI SI>> store it as MUSIC and and so run it. This avoid you to type everytime the musical note time and frequency, makig the program shorter:-) Kind regards, Carlos quote='matalog' pid='148834' dateline='1623101377'] (06-07-2021 12:11 PM)Joe Horn Wrote: Just a thought: In that case, the program might play smoother if you omit the inner loop, since the 50g supports list processing. Also, none of the variables are needed. Omit the 1 'N' STO, and replace everything after the end of the list with the following: That makes it run quite a bit faster, it's now better to change the note length to 0.1 to slow it down a little. I guess it will leave less time between beeps, which has to help. hanks for sharing that trick. [/quote] RE: My first program on HP-50g - Music. - Stevetuc - 06-08-2021 06:50 AM (06-08-2021 01:06 AM)CMarangon Wrote: Hello!The issue with this approach is it only covers 1 octave whereas the example tune is multi-octave. It could be extended by <note name> eg A-G <Accidental> sharp # or flat b And <octave number> 0..8 where increasing octave number represents a doubling of freq. Eg middle C is C4 But would need a bit more coding as there are up to 3 characters per note. https://en.m.wikipedia.org/wiki/Scientific_pitch_notation[attachment=9552] RE: My first program on HP-50g - Music. - BINUBALL - 06-08-2021 09:25 AM And you can't use # in 50g program name RE: My first program on HP-50g - Music. - Stevetuc - 06-08-2021 12:17 PM (06-08-2021 09:25 AM)BINUBALL Wrote: And you can't use # in 50g program nameAh well.. we could use the German system. There is no »flat« or »sharp«, just the suffixes »-es« and »-is«. However there is also no B ..H is used instead. RE: My first program on HP-50g - Music. - 3298 - 06-08-2021 04:03 PM (06-08-2021 12:17 PM)Stevetuc Wrote: However there is also no B ..H is used instead.Yes there is, Americans call the German B a B-flat instead. That's not even the only quirk of flats in the German nomenclature, the -es suffix gets shortened to -s on the vowels A and E, i.e. A-flat becomes As, E-flat becomes Es. Things get even more arcane in the designations for octaves, and if you want to be really accurate with those, you would break the 50g var-name requirements too. It's likely possible to deal with the challenges in a way that would let any professional German musician understand them, but probably easier for others to mix notations and keep the American octaves. Anyway, using dedicated programs to emit a single note with a BEEP command in each might save a small amount of storage space and/or some time typing, but it would definitely eliminate Joe Horn's speed boost, and probably slow it down beyond the original. If you insist on dedicated names for notes, store only the frequencies in them, and keep the durations and the BEEP command centralized. You may have to massage the list of notes with 1. \<< RCL \>> DOLIST to let BEEP see the frequencies instead of just variable names, but that's just a delay before the song starts, not between notes. RE: My first program on HP-50g - Music. - Claudio L. - 06-08-2021 06:46 PM (06-06-2021 07:02 AM)Stevetuc Wrote:(06-06-2021 06:49 AM)compsystems Wrote: Hello 3 years later and it's still in the todo list, it's low priority as it's a fun thing only. RE: My first program on HP-50g - Music. - Hlib - 06-09-2021 02:51 PM Have you tried code like << { Hz1 Hz2 Hz3 ... } { time1 time2 time3 ... } BEEP >> ? IMO, this is much more efficient. This syntax was added to C. BASIC for CASIO FX by analogy with the hp-50g. RE: My first program on HP-50g - Music. - BINUBALL - 06-10-2021 01:08 AM (06-09-2021 02:51 PM)Hlib Wrote: Have you tried code like << { Hz1 Hz2 Hz3 ... } { time1 time2 time3 ... } BEEP >> ? IMO, this is much more efficient. This syntax was added to C. BASIC for CASIO FX by analogy with the hp-50g.That's great way to use list processing. I have wrote code like << { Hz1 Hz2 Hz3 ... } time BEEP >> But I haven't known that kind of code working. And anyone can rewrite this code shorter? Code: << 440 1 BEEP 1 WAIT 440 1 BEEP >> RE: My first program on HP-50g - Music. - DavidM - 06-10-2021 12:17 PM (06-10-2021 01:08 AM)BINUBALL Wrote: If I can use WAIT in code more efficiently, then we can make better music My first thought upon reading this was: "what happens if BEEP is given an invalid frequency to play -- might it simply produce silence for the given duration?" Unfortunately, the answer is no. When I tested this with 0 for the frequency, BEEP simply ignored the input and the next note started playing immediately (ie. no pause at all). So I then thought a simple conditional test might work to either perform a BEEP for non-zero frequencies or a WAIT if given 0. This version uses DOLIST to take corresponding entries from two input lists (the first has the frequencies, the second has the durations). If the frequency is 0, it is simply dropped and WAIT is used with the given duration. Otherwise BEEP is used with the given arguments: Code: \<< The same logic applies to this version, which is a bit smaller at the expense of readability: Code: \<< I'm sure there's other ways to do this, but this was what came to mind when reading your question. - David |