# OutputResponse and RecurrenceFilter failure in WM10 with increased precision datasets

Suppose I import sound from file into data list, like this:

(Set file name and path)

    nFileName = "p:\\TrueOscill250HzLongNoHiss128kSps.wav";


(Importing available wave info from file header)

    nSampleRate = Import[nFileName, "SampleRate"]


(Import raw samples into 1-dimensional list)

    data = Import[nFileName, {"Data", 1}]


(And amplify it)

    For[i = 1, i <= Length[data], i++, data[[i]] = data[[i]]*2.74892];


data

I design then LowPassFilter as follows:

 LowPass = Rationalize[ToDiscreteTimeModel[BesselFilterModel[{2, 12566.307}],1/nSampleRate,
Method->{"BilinearTransform","CriticalFrequency"->12566.307,"StateSpaceConversion"->Automatic}],0]


and apply it over the data like this:

filteredsound = RecurrenceFilter[LowPass, data]]


The code runs smoothly and pretty fast, giving me low-pass filtered sound of 200,000 samples long, sampled 16 bit:

 ListPlot[Take[filteredsound, 2000], Joined -> True, DataRange -> {0, 1.63}]


But, once I tried to increase precision of data from default to say 16 digits, it only processes tiny portion of(100 samples or so) , and then numbers drop to zero with 10th at some huge power shown in red boxes in the output, and that's all :(

(*NB: I change precision of data at the import point, with SetPrecision[data,16], while 16 descriptors are added to all further numeric constants in the text)

De-Rationalizing filter doesn't change a thing. Rationalizing data inside the filter rather pushes the cores into infinite loop, eating memory at gygabytes rate per minutes and eventually runs out of it - and this is not due to Rationalization procedure itself.

OutputResponse behaves exactly the same way. Converting the transfer function into StateSpaceModel also doesn't seem to change anything.

Question: why simply changing precision from default to any other (even lower) ruins the symphony?!! Is there anything I can do to help it?

Thank you!

UPDATE1:

Bill kindly tested my problem and found no problem (see comments). However so far, I wasn't able to be that lucky. The code Bill provided does the same red box hell for me, and I don't know the reason why.

If anyone would like to test my notebook with own Mathematica, this can be downloaded from:

http://www.2shared.com/file/wVTQaGE_/playing_with_filters.html

Thank you!

• Can you be more specific about the format of your data? For instance, is it a SampledSoundList or a simple List? (use FullForm[data]). How have you changed the precision of the data? – bill s Jan 20 '15 at 16:23
• hi! I've tried both SampledSoundList and simple list as data, this introduces no difference to the problem. FullForm says the same formats. Precision is changed with SetPrecision[data] and assigning to the new var. I do not apply SetPrecision to the whole SSL :) – Sergiy Jan 20 '15 at 16:32
• Please fix the syntax errors in the definition of LowPass so that we can be sure to be running the same code (i.e. fix it so we can copy/paste it). Next, generate some random data that shows the same effect. If we can reproduce your problem, we can probably solve it. – bill s Jan 20 '15 at 16:45
• I appologize for inconvinience, here it is LowPass = Rationalize[ ToDiscreteTimeModel[BesselFilterModel[{2, 12566.307}], nSamplePeriod, Method -> {"BilinearTransform", "CriticalFrequency" -> 12566.307, "StateSpaceConversion" -> Automatic}], 0] and here you can download the original datafile 2shared.com/audio/WtXidega/TrueOscill250HzLongNoHiss128kS.html and nSamplePeriod is 1/SampleRate = 1/128000 – Sergiy Jan 20 '15 at 16:58
• I think you should edit your question to include the above (and any other) relevant information... – bill s Jan 20 '15 at 17:25

I'm afraid that I can't reproduce your problem. Here is what I did: load in the data from your .wav file, which i had downloaded to my desktop. If you look at data[[1,1]] and test[[1,1]] you will see that they are the same but for the extra zeroes on the end.

data = Import["Desktop/TrueOscill250HzLongNoHiss128kSps.wav"]
test = SetPrecision[data, 16];
RecurrenceFilter[lowPass,  test[[1, 1]]]


Compare this to

RecurrenceFilter[lowPass,  data[[1, 1]]]


and the answers are the same (but for the extra digits).

I suspect though that you may be laboring under a false impression (that by setting the precision to be higher, you will get more accurate filtering). This is not really true, since the internal calculations are not done in 16-bit, they are done in machine precision arithmetic.

• Thank you! What version of WM are you using? – Sergiy Jan 20 '15 at 21:17
• I am asking because this issue might be absent in 8 and 9... then, from your example it is not quite clear, did you use SampleSoundList or just raw data... and hence, it is not clear, do you apply Recurrence Filter over a data range or a single value as well. This makes difference because as I mentioned, it processes correctly some points, but then goes wild with higher Precision. Were you able to apply RF over the entire wave at high Precision? With the output not suppressed and compacted, did you observe any of red-boxed values? – Sergiy Jan 20 '15 at 21:25
• The variable data` has FullForm starting with Sound[SampledSoundList[...]]. The variable data[[1]] is the SampledSoundList[...] while data[[1,1]] is just a list of all the samples. This is what I did above. Use the code above and it works fine. I'm running Mathematica v10.0.2 and Mac OS 10.10.1. – bill s Jan 20 '15 at 21:34
• Could you please post your import string then? data=... – Sergiy Jan 20 '15 at 22:15
• It would be nice to close this case, but I cannot, because I cannot reproduce what Bill couldn't reproduce :) Bill, take another look at the update, please. Thank you! – Sergiy Jan 24 '15 at 3:34