• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bandpass/ Audio filter in java

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have being trying for days to do a band pass filter in java, but I cant understand how to do it, can someone help?

thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you have so far, and where are you stuck making progress?
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


but it doesnt work
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surely

is not a band-pass representation ! Can you provide a reference for this?

I would expect the input to the low pass filter to be the 'x' values and the input to the high-pass to be the output from the low-pass with the resulting output from the high-pass being the desired band-pass output.


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, what does it do, and how is that different from what you expected? Note that we have no idea what kind of data is in any of the variables, and how this piece of code should alter them.
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont understand how to actually calculate band pass...

wHAT I do here is that I calculate low filter and high filter and then use this values to calculate the bandwidth, or that is what i understood from my reading....

In the array there is all values of the notes in the possible audiofile (monophonic). So after doing yin process and getting a byte array with all the notes, I count them and group them by value and then try to filter them.

I want to here only the middle values without overtones, trying to clean as much as possible the tune.

Do I explain myself?
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a strong background in signal processing but I really don't understand your approach. I would suggest you spend some time researching digital filtering because you seem to be guessing.

P.S. A single pole high-pass followed by a single pole low-pass filter does not produce a very good band-pass filter and for any reasonable bandpass you are likely to need a multiple pole filter.
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read that for doing band pass filter the equation is:

q= fCentre / bandwith

where bandwith= fHigh-Flow...

so thats what Im trying to do...
in the line [\code] int temp= x_last/Math.abs(temp_high - temp_low);[\code]

isnt it correct?
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As an equation relating frequencies to Q (the sharpness of the filter) that is correct but it is not correct for processing the samples. Please research digital filtering.
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats the thing, I dont really understand!.. .... Im trying to do some programing not understanding physics...
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:Surely

is not a band-pass representation ! Can you provide a reference for this?

I would expect the input to the low pass filter to be the 'x' values and the input to the high-pass to be the output from the low-pass with the resulting output from the high-pass being the desired band-pass output.




Tell me just something, is my low pass/ high pass filter right?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

lea didio wrote:Im trying to do some programing not understanding physics...


I'd say that's the wrong approach - you can't implement something you don't understand. Follow Richard's advice and read up on signal processing first.
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

lea didio wrote:

Tell me just something, is my low pass/ high pass filter right?



You really mean "is my low pass/ high pass filter implemented right?" . In an earlier response I outlined what I would expect the signal flow to be but your code does not follow that. In addition I pointed out that even if you correct the filter it will not have a very high Q and a multi-pole filter is more likely to be required. The problem is I don't understand why you are doing the filtering. Yes you are trying to filter values outside some central frequency but why? What information are you trying to extract from the signal? If we knew the problem you are trying to solve someone here may be able to suggest an alternative solution.
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oK, Ill do my best to explain.

I have a wav file of one voice. After doing pitch detection I get samples. These sample I display them in a plot(like the plot below).
After that, Im suppose to notate the samples. So I run trough the list of samples and count the ones that are alike and join them to one, this way I get the length of each note so that they can be notated. I have the representation of the note in jfugue. Now, because of the algorythm and any other possible noice, my list to be notated contains notes that need to be out.
For example: if my jfugue string looks like these: "T120 [43]/0.77 [42]/0.75 [43]/0.7 [44]/0.02 [45]/0.68 [36]/0.02 [47]/0.2" then i want to delete [36]/0.02. I dont have any way of knowing that [36]/0.02 shoouldnt be notated and therefore i need a filter to clean clean the string and that way get to notate as close as possible to reality.

Did i explained myself?

thanks!!!
plot.png
[Thumbnail for plot.png]
the plot
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't fully understand but you seem to need to remove outliers which is most definitely not achieved by using a band pass filter. I can think of several approaches that would remove the outliers but you don't say what values they should be replaced by and without a better understanding I can't really suggest anything.

Out of interest, how did you achieve the pitch detection?
 
lea didio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we implemented yin pitch detection and then used jfree chart
 
Let's get him boys! We'll make him read this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic