Sending MIDI data using P1 COGS with Tachyon FORTH
I haven't chanced upon many examples of Tachyon FORTH code and none that help me understand how Cogs work. Below the most simple example demonstrating my question. And Merry Christmas!
( Thanks for the back ticks)
: mINIT 31250 SERBAUD ; \ sets MIDI baudrate : tx1 6 SEROUT ; \ data will be output by pin 6 : C3 $90 tx1 60 tx1 $127 tx1 500 ms $90 tx1 60 tx1 0 tx1 ; \ middle C half second : C2 $91 tx1 48 tx1 $127 tx1 500 ms $91 tx1 48 tx1 0 tx1 ; \ C one octave lower
** using Parallax P1 cogs and Tachyon, how to send these two notes to a MIDI device so they play at the same time?
Comments
Hi @rwl7532 !
To apply code display mode, add three backticks on the line before, and the line after your code. That way the colons and all other code elements will appear.
I've edited your post above to demonstrate.
Learning things every day! Thanks!
Hi,
You might want to try RUN or RUN: .
1 RUN: word
Will start the word in cog 1.
To make sure, that the midi code sequences do not get mixed up, you will need a lock. I don't know if the tx1 routine is designed to be used in parallel by multiple cogs.
I would try to avoid to use the same hardware by multiple cogs.
Good luck!
~~~~> @"Christof Eb." said:
I have a single cog working one time (using RUN:) but on completion I have to reboot to gain a usable prompt again.
And what is the difference between RUN and RUN: ?
Without using any COG, I can achieve polyphonic MIDI.
When I look at a musical score which has Treble and Bass Clefs (right and left hand usually for piano) it seems a natural thing to devide the work between two COGS. Certainly precaution (time pause?) need to be taken so one stream doesn't conflict with the other. Perhaps even use two different P1 pins (MIDI won't care)
Hi,
it is not clear, what you have tried. Its a few months that I have worked with P1 Tachyon. As far as I remember, RUN: worked fine.
I would suggest to experiment with RUN: with other words than serial first.
Do you know this:
[Glossary of Tachyon words - Google Docs](Glossary of Tachyon words - Google Docs)
And:
[Introduction to TACHYON Forth - Google Docs](Introduction to TACHYON Forth - Google Docs)
What Do you mean by this:
Without using any COG, I can achieve polyphonic MIDI.
If you are using P1, then you always use at least one of its cogs (cores). As far as I remember Tachyon starts the console on cog 0.
Good Luck.
Edit: The links dont work, you have to google....
What did I mean? Of course a cog is involved with any code on the P1. I meant I did not specify in code that a specific COG handle it. Hence the uppercase. That is all I was trying to convey. Maybe COG CODE is more to the point.
If you tried to start a second job in the same cog, that handles the console, then this would explain the crash?
Ah, I now had a look into extend.fth about RUN: .
It ist intended to be used inside of a code definition:
I wanted to look for "SETLOCK" and "CLRLOCK", which would be quite handy for your idea. It is really not available. Even for P2 Taqoz they are not present. Bob did some work there: https://forums.parallax.com/discussion/174667/taqoz-reloaded-v2-8-exploring-locks It would be possible to introduce them with this method: https://forums.parallax.com/discussion/173684/simple-assembler-for-p1-tachyon-forth-5-7-or-can-you-beat-tachyon-at-fibonacci#latest
It is kind of symptomatic, that the LOCK handling is not present in Tachyon/Taqoz: It is often only helpful to handle things with several cogs, if the dependencies are really small.
Proper Link now from my PC:
https://docs.google.com/document/d/1HuBe1ULFxHfmmJ9OOBhRPEQu_RZZlKEUsPTkz3E_80Q/edit#heading=h.q1879c607rq0
I had downloaded EXTEND.FTH some time ago. And there it is.
![](https://forums.parallax.com/uploads/editor/eo/sgqw15e0wrzr.jpg)
0033mer on YouTube had a video years ago I happened on after I started this thread.
Would be more useful if ATN?, ATN! we're defined.
For now I just do a messy REBOOT.