swharden / Spectrogram

.NET library for creating spectrograms (visual representations of frequency spectrum over time)
https://nuget.org/packages/Spectrogram
MIT License
308 stars 56 forks source link

Spectrogram Orientation #27

Closed padesso closed 3 years ago

padesso commented 4 years ago

Hi Scott,

I've been working with your Spectrogram for a few weeks and like it very much. I was able to integrate into my project but am considering updating it to support both the existing horizontal orientation as well as vertical. It's not a trivial change and I also don't think I can accomplish it without breaking changes. Do you have any plans to do so? Would it be an appealing PR?

swharden commented 4 years ago

Hi @padesso I'm happy to hear you're enjoying Spectrogram!

Adding a top-down orientation is a good idea. "Waterfall" displays are really common (especially in RF analysis) so supporting this makes sense. Probably the simplest way to do this is to add a bool horizontal = true argument to the Spectrogram.GetBitmap method:

https://github.com/swharden/Spectrogram/blob/555e1cc04457093751e5d3e7be4cc9493e6cb624/src/Spectrogram/Spectrogram.cs#L145-L146

...then add that same argument to the Image.GetBitmap method. You'd have to refactor this method a bit to support vertical orientation, but support could be added just by refactoring this method:

https://github.com/swharden/Spectrogram/blob/555e1cc04457093751e5d3e7be4cc9493e6cb624/src/Spectrogram/Image.cs#L13-L56

If you want to have a go at adding this feature you're welcome to make a PR! If you don't get around to it, I'll leave this issue open and try to support this feature some time in the future. Thanks for the suggestion!

swharden commented 4 years ago

... and perhaps a bool reverse = false argument would be helpful too? This could simply reverse the FFTs prior to plotting them, but the argument could control whether the waterfall display scrolls upward or downward 🤔

padesso commented 4 years ago

Thanks for the quick response! I think that by far the most common use case, and coincidentally mine for a radio project :) using this would be waterfall and particularly done in a way so it could be aligned with a graphical equalizer that shows peaks of the audio Your suggestion is certainly where I will start to look at this. There are some other more minor areas (like the scale bar) that will need to be touched but I aim to start looking into the implementation details in the evenings this week and will stay in touch on this issue with progres/blockers.

swharden commented 4 years ago

Sounds great! I'll keep an eye out for a PR, but let me know if you have any questions along the way.

You may find helpful code at https://github.com/swharden/FSKview such as Ruler.cs

padesso commented 4 years ago

Just checking in with you. I have the spectrogram in a waterfall orientation but need to complete some work on the scale bar and do some validation. I haven't been able to focus on it because of work but expect to pick this back up soon.

swharden commented 4 years ago

Just checking in with you. I have the spectrogram in a waterfall orientation but need to complete some work on the scale bar and do some validation. I haven't been able to focus on it because of work but expect to pick this back up soon.

Hey, no worries! I appreciate you working on it, and definitely take as long as you need to do it well 👍

I'm happy to leave this issue open a while longer so it stays on both of our radars. I'm happy to see what you come up with!

Best, Scott

swharden commented 3 years ago

I haven't seen movement on this for a while so I'll close this issue, but if/when the topic arises again I'll open this back up and pick up where we left off 👍