Maestro
Dave Higton (1515) 3534 posts |
That’s handy. So if the UpCall client calls my FastTicker module, it would get a millisecond tick number, and could timestamp the USB input to millisecond resolution? |
Dave Higton (1515) 3534 posts |
Wow. We are working with the same definition of “immediately”, right? Not waiting for a callback or anything? It’s more real-time than I thought. |
Colin (478) 2433 posts |
I would expect so. You do need to ensure that the USB buffer is emptied when you read it in the upcall handler otherwise you won’t get an UpCall_RXDataPresent upcall when new data arrives. Make the USB buffer 1 packet in size so that USB doesn’t wait for more packets and you get a packet as soon as it is transferred. The buffer is read with the BufferManager functions (not swis) |
Dave Higton (1515) 3534 posts |
By Jove. So we could conceive of a system where Maestro reads the FastTicker timestamp, adds a bit to give itself a bit of breathing space, and then sends note commands to a scheduler, which queues them in app’s time and trots them out in real time to USB. As long as Maestro can keep the queue from emptying, we would expect to hear music played fluidly. Some bits need filling in… The same principle could be applied to playback through the sound system. |
Dave Higton (1515) 3534 posts |
We could be back to the same MIDI fluidity that we had 30 years ago. |
Rick Murray (539) 13850 posts |
Wish I could say that about pop music… There’s a reason I mostly listen to a streaming station that only plays stuff from the eighties… |
RonM (387) 60 posts |
Removed post due to better MIDI pdf has been made available |
Andrew Conroy (370) 740 posts |
There’s a copy of the Acorn MIDI User Guide here if that helps. |
Rick Murray (539) 13850 posts |
And the user guide for mine which has a similar API and some expanded details… |
Alan Robertson (52) 420 posts |
Chris said.
Alan replied. |
Dave Higton (1515) 3534 posts |
My thanks to Andrew and Rick for those docs. Rick, I don’t know how you created that PDF, but !PDF on the BBxM takes about 2 minutes to render each page. I’m going to try another app tomorrow. |
Dave Higton (1515) 3534 posts |
On reflection, the only architecture that makes sense is for the USB MIDI module to claim a timer for itself and use it directly. Rick, I’ve got some code that you’re welcome to. |
Chris (121) 472 posts |
:) |
RonM (387) 60 posts |
the USB MIDI module I bought into a 32 bit driver for the Iyonix with the hope of using a 3rd party midi podule (Mr Gibson, I think) |
Rick Murray (539) 13850 posts |
Ron:
I would imagine there would be a lot of work to get the Acorn MIDI module working because:
Not to mention some differences in how USB MIDI works (packets) versus how serial MIDI works (bytestream). Thus, things like running status (a way of speeding up serial MIDI by simply discarding the “note on” bytes, they’ll be assumed if the following data isn’t a command) aren’t available. Plus fewer complications as data is sent as complete packets, no more malarky of having some types of status message appear in the middle of MIDI commands! Of course, if you have an actual MIDI podule, then the problem for you may only be the support of the IOC timer, asides from any technical 32 bit issues. Does the Iyonix fake IOC behaviour like the RiscPC does?
That’s probably it. Not many Iyonixen, even fewer MIDI podules… Dave:
I’m not sure about laying claim to an entire timer. It’s the most logical way for MIDI but maybe not for the rest of the machine. Aren’t timers generally in short supply? |
Dave Higton (1515) 3534 posts |
It’s what MIDI did 30 years ago, when there were only two timers available (and the OS was using one). Read the warnings in the MIDI User Guide. That said, does anybody know of any RISC OS software, other than (the OS using timer 0) and MIDI, that use a timer at all? The question is important. I’ve been thinking about starting a thread here with “IMPORTANT” in the title, to ask the question with a reasonable chance of getting a response. csap is the other forum I can think of. My BBxM has 7 timers, so it clearly isn’t short of them. I don’t know about the other platforms though. The other fundamental consideration, to me, is how the MIDI module gets control, reliably, every millisecond. Hanging on the IRQ vector works. Is there any other way? As Jeffrey (IIRC) pointed out, we really need a way to reserve timers. The old Device Claim protocol is sort-of there, but requires a Wimp task to be running. If we had to use that, the MIDI module would have to become runnable – and for that reason alone. TL;DR: I don’t think we have a real-world problem by taking control of Timer 1 for MIDI – if it exists; and the code to find out how many timers exist can be done in a single BASIC statement. If we were to straight 32-bit the MIDI podule code, it would of course claim Timer 1. |
Steffen Huber (91) 1953 posts |
I remember Druck’s “TimerMod”: https://armclub.org.uk/free/timermod.zip Is said to work on 32bit machines with “HAL features”. Worth a try? |
Rick Murray (539) 13850 posts |
Yes. Acorn made a module – TimeCode ? – that hijacks Timer1 for itself. I recall there was some annoyance about that back in the day, which suggests that others might have done likewise? Doesn’t IIC use the timer as well, or does it time delays from the OS timer?
Looks like the Pi has one free running timer with four interrupt generating comparison registers, two of which are claimed by the GPU. That’ll leave one for the OS and… https://embedded-xinu.readthedocs.io/en/latest/arm/rpi/BCM2835-System-Timer.html
Service call. Forget Wimp messages, they’re irrelevant. This stuff is going to be responding to IRQs and be running always, which means it has to be a module. A Wimp task isn’t up to the job and stands a very real chance of many missed events when paged out. A module is the only way forward, and modules have no problems with service calls. So issue one, see if it is claimed by anything. If not, you’re good to go (assuming other software obeys the same protocol).
Or not – I don’t expect poking around in IOC registers is terribly useful these days. I mean, if that worked, so would the Wimp2 module… ;-) |
jan de boer (472) 78 posts |
If hardware timers are in shoft supply, then isn’t it possible to use one timer for more tssks? Especially as there is a fixed ratio between centisecond and millisecond, isn’t it possible to program the (now in use for centiseconds) timer to millisecond intervals, dispatch 1 ms-events everytime and centisecond ones once per ten msec-ones? Perhaps a stupid idea, but that’s how it’s done/ can be done in an emulator: one (software) counter sliced down every emulated intruction; when it becomes <=zero the interupt-software looks which event is next in a linked list, and resets the counter to the time-to-go upto the next event; from time to time the system is calibrated with another, precise timer (hardware event/system time) resulting in a multiplication factor for use with the first counter. Something similar could be done with the ARM timers, perhaps? |
Martin Avison (27) 1494 posts |
does not use Timer1 – the help says… On Risc PC, A7000 and Archimedes machines the 2MHz IOMD/IOC timer 0 is used. On RISC OS 5 machines the HAL counter 0 is read, which on the Iyonix is provided by the XScale 80321 and runs at 200MHz. It also works on the Raspberry Pi which has a 1MHz timer. I also had a quick panic that my TaskUsage uses Timer1 … but although it used to many many years ago, it now just uses Timer0. |
RonM (387) 60 posts |
I would imagine there would be a lot of work to get the Acorn MIDI module working All above my head but I noticed the PRM reference has Service_MIDI |
Dave Higton (1515) 3534 posts |
If you have an app that wants to reserve a timer (or even to find out what timers are reserved), you can’t use a service call, AFAIK. |
Rick Murray (539) 13850 posts |
… Write a helper module, use that. Apps are high level things. Timers are low level things. Given the swap out nature of application space, there’s no way to have an app able to be called when a timer expires. The best you can hope for is “soon” if you set a pollword. It’s like apps drive on the left, modules drive on the right… |
Steffen Huber (91) 1953 posts |
This is surely a good thing rather than a bad thing? At the end of the day, who cares which timer is used, as long as it is properly abstracted away and gives the necessary resolution (as far as I understood so far, microsecond resolution would be good enough). |
Chris Evans (457) 1614 posts |
The TimeCode Reader Podule was sold by Uniqueway. We have a new one in stock! It was used in conjunction with Sibelius. |