Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20 memory slots and squelch/gate #23

Open
Roturbo opened this issue Apr 21, 2022 · 13 comments
Open

20 memory slots and squelch/gate #23

Roturbo opened this issue Apr 21, 2022 · 13 comments

Comments

@Roturbo
Copy link

Roturbo commented Apr 21, 2022

Hello Graham, is it possible to increase the slots to 20 ?

How about a squelch/gate to make noise floor complete silent and only voice open the audio ?

Just ideas to make it better.

Tanks for your amazing project.

@grahamwhaley
Copy link
Owner

Hi @Roturbo - thanks for your questions :-)

  • The memory slots - if I remember correctly, the number of slots is dictated by the amount of eeprom space available on the Teensy board. The Teensy 4.0 I used only has 1080 bytes of emulated eeprom - not an awful lot of space. You might be able to squeeze few more slots if you can manage to reduce or pack the memory slot structures closer, but I suspect not many. To see how much space is currently used you can add a print statement to the code to see how big the factory_default_settings structure is: https://github.com/grahamwhaley/DSPham/blob/master/settings.cpp#L24

    Alternatively, if you used maybe the Teensy 4.1 instead, it has 4284 bytes of eeprom, so you should be able to fit the 20 slots in :-)

  • On the noise gate - I think it's possible to add one. There is a teensy audio library example over in the OpenAudio library that has a noise gate: https://github.com/chipaudette/OpenAudio_ArduinoLibrary/blob/master/AudioEffectNoiseGate_F32.h

    As far as I know, the OpenAudio library is a 'drop in' library that builds on top of the original Audio Library, so it should not be hard to either port that noise gate code across, or to start using the OpenAudio library with DSPham, and it should already build and work I think... but, I've not tried it.

Personally, I have no plans (or right now time) to try either of these out, but if you are code capable and want to give this a try then I will of course give you any help, pointers and advice I can.

Let me know if you have or are building a DSPham - I'm always interested if people build one and how it performs etc.

@Roturbo
Copy link
Author

Roturbo commented Apr 21, 2022

Hi Graham, i know very little about programing, i was able to increase the slots to 20 and disable the Morse menus,
but i get a NAN, (not a number) on the Volume menu, it was a basic solution.

I have notice OpenAudio library before, the problem is to insert it on the code and creating a menu to increase or decrease the
gate levels, or to make it "smart" in a way to detect were there is no voice (flat noise) and were the voice enters, transitions
must be smooth, the delay must be adjustable etc.

And yes, i have build a DSPham, it works amazing in my case, i can tell you it is not perfect, it needs much RF filtering, not only
the RF that comes from the radio, but also the clocks and oscillators from Teensy and the audio board, i have one SDR connected
to the IF of my radio,, and i can see very strong signals on 3mhz, 10mhz etc, with a small antenna that signals go over 2 meters,,
sometimes the signals oscillate depending on the voice levels,, and as you imagine, were that signals beat there is no way to
listening the stations, this is the 600mhz Teensy working inside a aluminum case not free air.

In SSB many stations come mixed with band noise, and some of them don´t have good audio, the DSPham can clear the
noise and make the audio more linear, smooth and clear, with low noise radios it is like FM,, no noise, only the voice is
coming out of the speaker, if there is some noise on the band or with radios that have more noise,, than on moments
were no one is talking you get like drooping water noise (bubbling) as many other DSP, and here is the reason for the squelch/gate.

I´m going to read more about the Audio Library, maybe i can add it to the code and make it work.

Tanks for your replay, i will keep you informed.

@grahamwhaley
Copy link
Owner

Hi @Roturbo .
Heh - the NAN for the volume is probably because when you increased the slots to 20, it made the eedata structure too big. As the volume parameter in that structure is near the end of the structure, it probably 'fell off' the end of the eeprom space, so when the unit boots it reads back garbage, and translates that to a NAN.

The RF filtering and noise interference - yes, I had some of that on my initial build. Most of mine was coming from the regulator though - once I added more capacitor filtering around my 7805 a lot of my noise disappeared - but, that may not be your issue.

The trick is going to be figuring out how the noise is getting into the DSPham - is it coming down the audio leads, or the power cable or USB lead. When using my DSPham with my Xiegu G90 I did put an audio isolating transformer between the G90 and the DSPham - something like https://www.aliexpress.com/item/1005001604545947.html for example. The other thing you can try is wrapping the cables through ferrites or using clip on ferrites. This is not something I can fix in the software ;-)

Also, watch out for the input volume - if it is too loud for the DSPham then it starts to 'clip', and the audio starts to crackle. I added the ! warning symbol on the volume display to try and indicate if this is happening.

I'm really glad the DSPham is working for you! I'm going to presume you are using the 'spectral' noise reduction. I'm currently porting that code over to the open audio library. One thing you could try to reduce the 'watery' effect during silence is to increase the NR_alpha value. In DSPham it is default of 0.95 - but whilst working on the OpenAudio port I find that a value of 0.98 is less watery and does not impact the noise reduction too much. You should be able to adjust this through the menu (it is called Kim Alpha I think - as the NR_alpha variable is shared between the Kim and Spectral noise reduction code), or you can just try changing the default in the code and reflashing/resetting your unit.

I'll be offline for a week or so now - so if I don't respond right away it's not that I'm ignoring you - I'll check when I get back to my desk :-)

@grahamwhaley
Copy link
Owner

Hi @Roturbo . Well, I'm back at my desk, so can try to answer any further questions you might have.

I did have a thought - which I'll write here in case it is useful to you or possibly others in the future....

If you do add the squelch function, then there are two 'functions' on the rotary encoder which I think are not currently used in DSPham that could be tied to the squelch to make it easier to access from the 'normal' mode, and avoid having to always go into the menu...

  • long press
  • double click

Right now, when not in menu mode, I think we only use:

  • rotate - is change function
  • click - is enter menu

so you could have a long press or a double click enter a new mode - 'adjust squelch' maybe. Just a thought. It would require some programming around the Encoder enc1 object in the main .ino file to detect the long press or double click, and then some extra code inside the if (in_menu){...} else { code to handle the squelch.

@Roturbo
Copy link
Author

Roturbo commented May 8, 2022

Hello Graham.

The noise is more interference sometimes from the radio in TX (RFI) other times is the
DSP that produce harmonics that interfere on some low frequencies.

I manage to attenuate the Teensy harmonics using an RC, on the 5v input i use a 3 ohm
resistor and next a 1000uF/6v capacitor, some ferrites also help, but there are strong
signals that can pass on audio amplifier to the speaker, all can be cleaned, we
just need to see were they are.

The clipping i have it controlled, i manage to add a small audio amplifier inside the box,
also made a true Bypass for real comparing of original and filtered audio.

Let me tell you, the encoder (the ones from Grove) i have to struggle to make it work,
before the menu it was more or less working, but inside menu i have to change the code
because one step make it advance 2 places on the menu, if i move very slow i was able
to see one more option.

I have made some changes on code so now i can go to 0.99 on the NR-Alpha, the watery effect
it is not present all the time, it depends on radio filter and noise of the band, it is really
noticeable if no one is talking, that's were the idea of the audio squelch call my attention.

About your last message.

Yes, i know about the long press and double click, the double click inside the menu is the BACK
function one level up, but as you say, in normal mode it does nothing, so it is a good idea to
use that function, double click enter the squelch menu, but that is over my knowledge.

My programming skills are very low, i take some time reading the web to find the code to
make the audioConnection work on USB on the 2 directions, now i can pass the cleaned audio from the
DSP to PC and record it, or i can send the audio from PC over USB and use the DSP as a filter.

I was also able to make a second OLED 1.3" 128x64 LCD work in parallel because it uses different
address on I2C, but i don´t know how to convert all the menus etc for the OLED, also intend to
use FFT spectrum analyzer but the know how is missing, so i remove it.

I really don´t plan to make a fork of your work, but i want to work with you to make
this DSP better, later i can send you more details about my building, and some audio
samples to verify the quality.

And thanks, your DSP can remove most of the annoying noise from most radios,
and the auto notch filter works just as well.

@Roturbo
Copy link
Author

Roturbo commented Jun 20, 2022

Hi Graham, i leave here some pictures of my first unit made in a small alu box.

DSP

b8a85410-f757-471f-8ad3-742214e9def4

11

bd2c8db6-9784-43e2-95f7-6e13cb09f50e

Regards

@grahamwhaley
Copy link
Owner

Hi @Roturbo - thanks for the pictures! That looks like a nice compact unit - and you have squeezed in some more features - I presume at least one of the extra rotary controls is for volume, and the switch is for power? Looking nice :-)

Did you manage to make your rotary encoder function correctly, and not 'skip' and do 'double steps'? My guess is that your encoder has a different number of ticks-per-detent than mine. Somebody else saw this before (even though both encoders were labelled/sold as ky-040) - there is a note on the home page about the code you have to change to cater for different encoders - if you've not seen it, its in the section https://github.com/grahamwhaley/DSPham#hardware-choices . If you have issues with that, ping me and I'll stare at the code again. I think a change would need to be made in two places - one for the menu system and one for the 'default' screen - they use different encoder code I'm afraid.

Just for reference, I don't know if you saw, but the Spectral Noise code got merged into the open audio library :-) chipaudette/OpenAudio_ArduinoLibrary#13

@Roturbo
Copy link
Author

Roturbo commented Jun 22, 2022

Hello Graham,

This was in fact a very small case, i have add the VU leds later,,, the left button is to control the input signal , 5 or 10K,
on center is the BYPASS switch, this way i´m able to change from normal with noise to DSP audio,, than
on the right, it is a cheap 3w amplifier that also have included a switch, this i use to power also the teensy,

Later i have to add a 3ohm resistor and a big capacitor as a RC filter to avoid signals coming from the Teensy
and enter the audio amplifier,, this signals also go out the box from the speaker line.

The rotary problem yes i have face it 2 times, at first with that encoder, and later again with other encoders
that i buy from different place that were also different, and you are correct, i have to change it in 2 places,
it starts to work better, but never perfect, i have use the same encoders with DDS and other projects and
they are working perfect, no missing or double steeps,, the changes i made in code i have to use it not
too fast or i start to have missing stpes.

About the Noise Gate, i just read the link now, tanks to tell me, at start i have many problems like @NickTheVic,,
with DSPHAM, it was my first challenge on this project, get the correct files to make it compile.

On that link you are talking about change the filter from 100-3600 to 300-2800, from my experience this
should always be and adjustable option, i notice that the "watery" is the same if i use a 50-4500 filter, and
some stations on SSB use larger filters to transmit better audio quality, that you will not ear if is not
possible to adjust that filter.

But my knowledge is very limited on coding, i can change what is already made and copy parts of code from
other projects and use it, and i would love to add that adjustable "GATE" or "virtual squelch" to silence all noise
if there is no audio voice detected,, maybe in future you can give me some help, i notice on that link that
you don´t have time now.

I read about the syllabic rate detector module, but did´t find any code based on this type
of voice detection. http://www.naval.com/vos/

I have made some changes inside the code that i need to find to tell you what i have made,
i think it was one VAR related to Alpha were it have 0.99 i change it to 0.998, than it can go
to 1 without removing all the audio,, but voice is not totally clear,, and yes, 0.99 is the less
noise and "watery" in my case, it depends on radio noise.

Other option that i struggle to add was the UPDATE function without pressing the teensy button,
a simple routine that do the same inside the menus, this way there is no need to open the case
if i want to enter that mode.

Just remember, KIWISDR is also using spectra and LMS filters, but spectra is the best.

i will be out for some days, but i will try to post pictures of the V2, i have build 3 units for my friends,
later i have build 10 units of the final V3 for the other ones that also like it,, but will not build more, the material
cost more than 100€,, than there is CNC cutting, printing the labels and some hours of work that never end.

For the moment i only think in make the software better with that gate to remove the "silent" parts
were there is no audio and the watery starts rising,, (SSB squelch), we may also think about it as
an inverted VOX because it have similar function.

Regards,

@grahamwhaley
Copy link
Owner

Hiya,

The rotary problem yes i have face it 2 times, at first with that encoder, and later again with other encoders that i buy from different place that were also different, and you are correct, i have to change it in 2 places, it starts to work better, but never perfect, i have use the same encoders with DDS and other projects and they are working perfect, no missing or double steeps,, the changes i made in code i have to use it not too fast or i start to have missing stpes.

I'm going to guess you have the missing or double steps only in the default mode, and not inside the menus. The missing step problem is very likely as I implemented some very rudimentary 'debounce' code](https://github.com/grahamwhaley/DSPham/blob/master/DSPham.ino#L520-L523) :

  const unsigned long debounce_gap = 250;  //ms
...

  if (enc_change != 0 )
      {
        // Are these clicks too close to the last set - if so, drop them to 'debounce'
        // We could also use a state filter to do this as per https://www.best-microcontroller-projects.com/rotary-encoder.html
        // state=(state<<1) | digitalRead(CLK_PIN) | 0xe000;
        if (ms > last_change + debounce_gap ) {        
          if (enc_change > 0) {

So, if a 'click' turns up before 250ms is passed, it gets ignored. That's not idea I know, but it was a quick fix to a bouncy encoder problem. The 'real' solution is to write some better debouncing code there, or to use a better encoder library :-) The decoding library used inside the menu system seems fairly robust, so we could just copy what that does :-).

You could try reducing the 250ms timeout which should improve things maybe.

Other option that i struggle to add was the UPDATE function without pressing the teensy button, a simple routine that do the same inside the menus, this way there is no need to open the case if i want to enter that mode.

afaik, as long as your teensy has booted and is connected to the USB, then the teensy loader should be able to reset and reflash it without you needing to press the button. I just tried that here (with a different Sketch, but on a Teensy 4.0), and it worked. Only if your teensy is crashing and not connecting to USB should you need to press the button I think. That is part of the reason I added an external 'program' button to my DSPham box (on the back), so I could reprogram it if I crashed or corrupted it during development, without having to take the lid off :-)

i will be out for some days, but i will try to post pictures of the V2, i have build 3 units for my friends,
later i have build 10 units of the final V3 for the other ones that also like it,, but will not build more, the material
cost more than 100€,, than there is CNC cutting, printing the labels and some hours of work that never end.

Wow - you built how many!! 😄 That's amazing @Roturbo . I think that is by far the most anybody has built. I'm so glad it is working for you!

For the moment i only think in make the software better with that gate to remove the "silent" parts were there is no audio and the watery starts rising,, (SSB squelch), we may also think about it as an inverted VOX because it have similar function.

Sure. I think there are two ways that might be done:

  1. add 'automatic muting' to the spectral code, so that when the VAD code detects there is no voice it can mute the output
  2. add a universal 'squelch' using the code from the OpenAudio library, which could then be used for all the NR modes.

I'm still not sure if/when I'll find time to look at that though :-(

@Roturbo
Copy link
Author

Roturbo commented Jul 3, 2022

Hello again.

I did also have problems inside the menus, i remember that at start i have to turn the encoder very slowly,, it was like
the encoder was reading the half steps, than i change something that make it work better, still, with limited speed,
if i go faster the menus didn´t change.

So, if a 'click' turns up before 250ms is passed, it gets ignored.

This was changed to 100ms,, but depends on type of encoder.

That's not idea I know, but it was a quick fix to a bouncy encoder problem. The 'real' solution is to write some better debouncing code there, or to use a better encoder library :-) The decoding library used inside the menu system seems fairly robust, so we could just copy what that does :-).

https://github.com/gi1mic/DSP-Speaker-Filter/blob/master/code/GI1MIC-DSP-Filter.ino

Before your project i have build the one in the link,, with same encoders this one works fine, maybe
you can try that one, or any other that is not sensitive to different type of encoders.

Wow - you built how many!! 😄 That's amazing @Roturbo . I think that is by far the most anybody has built. I'm so glad it is working for you!

I think that i have build 1 test unit, 3 for beta testers and 10 for friends that want to have a more comfortable time
in front of the radio,, and i´m done, now if anyone wants he have to buy the parts and build it.

Sure. I think there are two ways that might be done:

add 'automatic muting' to the spectral code, so that when the VAD code detects there is no voice it can mute the output
add a universal 'squelch' using the code from the OpenAudio library, which could then be used for all the NR modes.

The adjustments is always a must, in any of the cases we must be able to adjust the threshold, the rising and fallowing or maybe
make it work almost like and AGC,, slow med fast etc,, because in SSB there are many audio pauses, and it may become
annoying if the squelch is kicking in the wrong way on each audio pause.

I'm still not sure if/when I'll find time to look at that though :-(

I will wait, and i will keep telling you the few things i have done,, for example, i have overclock the CPU,
it is running at 700Mhz,,

Next is the V2,, with many mistakes to correct.

1

2

3
4
m/91867260/177026941-e6da8fb0-9ba9-4668-a07f-d67db0d71926.jpg)
5
6

@Roturbo
Copy link
Author

Roturbo commented Jul 18, 2022

Hello Graham, next is the final version that i made, still have some mistakes but is better than previous one.

RXA and B are the inputs from 2 different radios, the upper switch chose the output direct from internal amplifier
to a speaker or Line Out to use external amplifier.

3

5

1

2

6

7

I will try to make some recording original and after DSP for comparing.

@kabidey
Copy link

kabidey commented Jan 20, 2023

i have finally made one. works very well.
IMG_20230111_142238
IMG_20230111_142301
IMG_20230118_014533

@grahamwhaley
Copy link
Owner

Hi @kabidey - excellent! Ooh, with built in speakers and amplifiers! I'm glad it's working well for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants