Intercepting the sound output

discuss bbc micro and electron emulators (including mame) here!
Post Reply
User avatar
pixelblip
Posts: 2388
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Intercepting the sound output

Post by pixelblip » Thu Sep 10, 2020 7:22 am

Hi
I often think of this idea but think if I ask the question it might be met with a full stop!

How easy do you think it might be to capture the sound output from an emulator and pipe it to something else ...so it plays wavs rather than beeps or even midi?

I've always loved the Island logic music system over the years. It records via the qwerty keyboard easily and has a great editor. I find it much easier to use than the music 5000 editors. Its just the bleeps however charming leave me for wanting the sounds of music 5000. The Hybrid music junior software looked so cool and much more user friendly but I have never seen it here on Startdot..and indeed if it were ever released.

There was a program that was meant to do this Hybrid released but I have asked on the forums in the past and never heard back ..and I don't have a bbc or a real music 5000.

What would be great is to be able to I capture the sound command in the emulator and pipe it straight to a soundfont player.
Its a bit whacky but I'll see what folks think.
I am still learning Ample which is really what I should be using of course...i could use a modern day sequencer and the sounds of music 5000 ...but I really like Island Logics music system.
It could be great with some teletext animations .
Thanks
Last edited by pixelblip on Sat Sep 12, 2020 10:06 pm, edited 3 times in total.

User avatar
tricky
Posts: 4795
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Intercepting the sound output

Post by tricky » Thu Sep 10, 2020 9:11 am

If it is only writing to the sound chip, then I don't see how you could reconstruct anything more than the frequency and volume.
If this is enough, b-em has a write VGM option that writes the sound chip register writes to a file which should be easy to re-purpose to stream out. I think they are only once per 50Hz, but all emulators will be modelling the same behaviour and so should be able to send the register values with more precise timing if required.

User avatar
pixelblip
Posts: 2388
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Intercepting the sound output

Post by pixelblip » Thu Sep 10, 2020 9:51 pm

Thanks Tricky that sounds interesting....

Really I need to get to grips with Ample some more but time is so limited.....maybe I can have a look at what you mentioned. I always thought The Island Logic Music System was so well thought out.

User avatar
Richard Russell
Posts: 1716
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Intercepting the sound output

Post by Richard Russell » Thu Sep 10, 2020 10:43 pm

tricky wrote:
Thu Sep 10, 2020 9:11 am
I think they are only once per 50Hz
The step-length specified in the ENVELOPE statement is in units of 1/100 s, not 1/50 s, so I have always assumed that was the timing resolution (certainly it is in my BASICs, for example I generate blocks of 441 samples at 44.1 kHz sampling).

But if the OP wants to map SOUND to a WAV file or to MIDI, doesn't he need to intercept the SOUND statement itself, not the low-level interface to the chip? I would have thought hooking into OSWORD 7 might be the way to go.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
tricky
Posts: 4795
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Intercepting the sound output

Post by tricky » Fri Sep 11, 2020 1:07 pm

I was talking about the "sound output" in a way that should keep the information, but SOUND should also work if the app uses SOUND, but that would require "hacking" the OS, rather than the emulator.
The 50Hz is referring to what I think is a limitation in the current VGM export for b-em.

User avatar
jgharston
Posts: 4179
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Intercepting the sound output

Post by jgharston » Fri Sep 11, 2020 6:10 pm

tricky wrote:
Fri Sep 11, 2020 1:07 pm
I was talking about the "sound output" in a way that should keep the information, but SOUND should also work if the app uses SOUND, but that would require "hacking" the OS, rather than the emulator.
No, just intercepting WORDV, just as *MIDI.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
tricky
Posts: 4795
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Intercepting the sound output

Post by tricky » Fri Sep 11, 2020 6:57 pm

I knew if there was a good answer you would have it.
Does it show that I only use the*fx call that tells you what the OS is?

Coeus
Posts: 1900
Joined: Mon Jul 25, 2016 12:05 pm
Contact:

Re: Intercepting the sound output

Post by Coeus » Fri Sep 11, 2020 8:27 pm

In B-Em we already have the ability to record the Music 5000 output as a WAV file. The same could be added for the built-in sound chip (SN76489). What we can't do is record the combined output because several of the sound outputs work at different sample rates and B-Em does not do the resampling it hands this off to Allegro which probably either uses OpenAL to do it, or passes it on to the host's sound system .
It would be quite easy to capture the SOUND commands by intercepting OSWORD calls. B-Em has a service ROM for VDFS that can be used to intercept OS calls and forward these to the emulator's C code. That could be used, for example, to write a MIDI file from those sound commands. There is a decision to make here, though. Should ENVELOPE just be ignored, on the basis that it is part of defining the sound of the instrument for that channel and the MIDI output would be played on something else with its own idea of what instrument it is implementing?

It would also be reasonably straightforward to make the SN76489 emulation output MIDI events - the frequency would have to be quantised to a MIDI note number, amplitude would be mapped to velocity. There is function sn_fillbuf, called periodically which could check each channel to see if a sound is still being played (amplitude != 0) and whether it has changed since last time to issue the relevant "Note On" and "Note Off" events. This would include the ENVELOPE processing too, though, as this is done by the OS. It could generate rather a lot of MIDI events but maybe no worse than aftertouch.

Then should the emulator generate live MIDI or MIDI files? Live MIDI would probably be better because then you can run a softsynth at the same time as the emulator and, if you really wanted a MIDI file, there must be applications that can receive live MIDI, do the inter-event timing and write a MIDI file. That may not be particularly OS independent, though.

User avatar
Richard Russell
Posts: 1716
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Intercepting the sound output

Post by Richard Russell » Fri Sep 11, 2020 10:57 pm

Coeus wrote:
Fri Sep 11, 2020 8:27 pm
There is a decision to make here, though. Should ENVELOPE just be ignored, on the basis that it is part of defining the sound of the instrument for that channel
FWIW I would say yes, ENVELOPE should be ignored.
I am suffering from 'cognitive decline' and depression. If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

User avatar
pixelblip
Posts: 2388
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Intercepting the sound output

Post by pixelblip » Sat Sep 12, 2020 4:58 am

Thanks everyone! I wasn't expecting so much help with this question.

That is exciting Coeus! I know you spent quite a bit of time helping me get Music 5000 working and sorry it has been a bit under utilised. It's just for whatever reason using the emulation of it and recording is not so easy. The Notepad in Music 5000 also has some strange quirks generally. I seem to recall you can't scroll a page of text in it without losing it off screen! That makes life difficult. Hats off to the Ample musicians of old as it is not so easy.

If b em could output that sound data as midi that would be fantastic. Live even better. We might have to experiment to see if the timing is ok and if not a midi file produced instead.

I wouldn't worry about envelopes. They can be set after.....

I had a very as a very crazy idea in my head recently to build Music 5000 keyboard with a sequencer all built in. If you can get this midi working it might come to life! The amount of crazy ideas I get....

I find Island Logics program so easy to use. Even after all these years later it still impresses me and I still feel that magic firing it up. What a dream come true that would be to see it running playing music 5000 sounds 😀

User avatar
pixelblip
Posts: 2388
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Intercepting the sound output

Post by pixelblip » Tue Oct 13, 2020 9:44 pm

Well still hoping here.....
I came across beebugs studio 8 a while ago. Another great bit of music software. Funky interface. I remember back in the day thinking what is that when I saw it..

It would be great to feed this program out into a midi stream. Very interesting results could be had.......

User avatar
pixelblip
Posts: 2388
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Intercepting the sound output

Post by pixelblip » Sat Oct 31, 2020 1:20 pm

I am going to keep pestering you Coeus!
Studio 8 is tooo cool. It's so advanced. Respect to Beebug!

It would be *great* to see this trigger some midi or some sounds from B-em! I am trying to write some Halloween music as we speak.
Attachments
Studio 8.png

Coeus
Posts: 1900
Joined: Mon Jul 25, 2016 12:05 pm
Contact:

Re: Intercepting the sound output

Post by Coeus » Thu Nov 19, 2020 9:27 pm

It's a great idea. It turns out not to be quite so simple as I had first thought, though. Intercepting at the OSWORD level means the emulator then has to do things the BBC OS would have done previously such as synchronising the start of notes that form a chord. That's doable, of course, but I find it much more difficult to find time for something complicated rather than quick hack.

User avatar
pixelblip
Posts: 2388
Joined: Wed Feb 04, 2015 7:19 pm
Location: London
Contact:

Re: Intercepting the sound output

Post by pixelblip » Sun Nov 22, 2020 7:08 am

Ah ok....
Thanks so much for looking at it. I know you like a challenge! :lol:
Don't worry if it takes too much time.

I can't believe how advanced Studio 8 is. It's like Ableton live but 30 years ago. I want to build a little keyboard for it now......and use it.
It's very quick to put stuff down in it.

I have finally got B-em back on Linux now. Thank goodness. I got errors compiling but I used the autogen git and that worked. I had a brand new Ubuntu 20 so not sure there......anyway at least I can have another bash with Music 500/5000.
I do constantly read the Hybrid manuals when I wake up but I find the chans voices players all very confusing and often get no where. Studio 8 would be much easier! Also Island Logic Music system and midi would be really cool. I always liked the simplicity of that program. The problem there is I guess it uses every trick in the book to keep the program going at it's speed with the sync like Studio 8. Well at least you can have a think about it whilst shopping in the supermarket........

Thanks again for plugging away Coeus....you have been great and very helpful. We all help each other here don't we. :D

Post Reply

Return to “8-bit acorn emulators”