tonyc / open890

A web-based remote UI for the Kenwood TS-890.
Other
79 stars 6 forks source link

Streaming audio TO radio #6

Closed tonyc closed 10 months ago

tonyc commented 3 years ago

Is there a way to capture PCM samples in the browser?

Required for full remote TX operation

Tyrbiter commented 1 year ago

This would be a really excellent feature addition Tony, I hope you are able to consider it soon.

tonyc commented 10 months ago

I have the basics of this working in spike/audio-tx, but there is a lot of cleanup to do. I suspect I will have this shipped by the end of this year, though.

Tyrbiter commented 10 months ago

Is it worth having a go with this now @tonyc or perhaps wait until you have done more cleaning up?

tonyc commented 10 months ago

I'd say wait a little bit until I get it cleaned up. Once it is usable, I will just merge it straight into main.

There are a couple extra buttons in the UI that I was using for debugging, sort of like a manual PTT, because I wasn't sure how to get it working with the radio's SEND button, but I've got that figured out now.

Surprisingly, once I started to dig into it, it wasn't all that hard of a problem.. I probably could have had this working a couple years ago 😆 The main issue I ran into was realizing that the audio (both in and out) aren't 8-bit values, but 16-bit unsigned values. So I ended up needing fewer samples per UDP packet, but then I needed to figure out how to split e.g. a 16-bit unsigned value into its two separate bytes, to stuff into the UDP packet.

The other problem I ran into was with loudness. The JS audio library I'm using gives me sample values in the range of -32768 ... 32767, and the "loud" values of the audio samples were way too loud, so I had to scale them all by .002 to not blow out the audio.

Once I got the byte formatting and the audio volume figured out, it all pretty much just worked - and I had a SSB contact using the app earlier today!

Tyrbiter commented 10 months ago

OK, I will watch with interest and see how things progress.

tonyc commented 10 months ago

@Tyrbiter I just had my second-ever SSB QSO with open890 on this branch, feel free to pull it down and give it a shot.

You will need to hold the DATA button and set up the rear SEND/PTT like this:

20231217_140836

This config will let you use the SEND button to transmit.

Make sure DATA VOX is off, otherwise it will operate with VOX, which you probably don't want.

Click the "VOIP MIC: OFF" button at the top, and your browser will prompt you for permission. Make sure to choose the correct audio device, otherwise if you accidentally choose the TS-890's USB audio device, you'll create some great feedback:

2023-12-17_d6cd

You may need to reduce the KNS audio level, and also your OS-level mic level.

The KNS config is at: MENU -> KNS -> CONFIG -> Audio Input Level (VOIP)

I've got mine set to 25, and it seems to give good results.

tonyc commented 10 months ago

Actually, I've just merged this into main and deleted the branch. I have a couple of other QOL cleanup things to do, but this is mostly finished.

Tyrbiter commented 10 months ago

Just saw this, I will have a play and see what I find. I think this is where a macro or two will be needed to set up the audio paths, I currently use audio over USB using freedv in analog voice mode.

Thanks for all the work!