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?
Note: you can download datafile (410KB) from http://www.2shared.com/audio/WtXidega/TrueOscill250HzLongNoHiss128kS.html
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!
data
? For instance, is it aSampledSoundList
or a simpleList
? (use FullForm[data]). How have you changed the precision of the data? $\endgroup$