The KiwiSDR 2 online store is open for orders! Please visit kiwisdr.nz
How do I change the kiwiclient wav output samplerate?
Anyone;
I would like to use kiwiclient to record a short wav file which I can then process as an input file in ARGO. I have searched the messages here, and also done some study of the kiwiclient python code. So far nothing has jumped out, to point me in the direction to accomplish this objective.
The issue is, ARGO requires the input wav file to be sampled at 6000 samples/sec. Kiwiclient outputs the wav file at 12001 samples/sec. I have taken the output wav file and resampled it down with Audacity. The resulting file is processed correctly by ARGO. The resampling steps with Audacity requires manual input which is extra work to process a number of captures. I would like to change Kiwiclient to output the 6000s/s rate, but so far I don't understand how to do that. I know only a little Python, and very little about the included subroutines.
For now, I will continue to plug thru the code hoping to find the light switch. Any help or pointers would be appreciated.
Mike N8OOU Thanks and 73
I would like to use kiwiclient to record a short wav file which I can then process as an input file in ARGO. I have searched the messages here, and also done some study of the kiwiclient python code. So far nothing has jumped out, to point me in the direction to accomplish this objective.
The issue is, ARGO requires the input wav file to be sampled at 6000 samples/sec. Kiwiclient outputs the wav file at 12001 samples/sec. I have taken the output wav file and resampled it down with Audacity. The resulting file is processed correctly by ARGO. The resampling steps with Audacity requires manual input which is extra work to process a number of captures. I would like to change Kiwiclient to output the 6000s/s rate, but so far I don't understand how to do that. I know only a little Python, and very little about the included subroutines.
For now, I will continue to plug thru the code hoping to find the light switch. Any help or pointers would be appreciated.
Mike N8OOU Thanks and 73
Comments
One thing I found was from the alternate Kiwi UI from linkz (https://github.com/llinkz/directKiwi) written in Python, that uses the resample_poly() function from the scipy.signal package. Some of the difficulties resampling audio in Python are discussed in this blog post: http://signalsprocessed.blogspot.com/2016/08/audio-resampling-in-python.html The resample_poly() solution is mentioned in the comment section of that post.
As long as there are not major problems installing scipy on most OSs (similar to how kiwiclient requires the numpy package to be installed) then I don't see why an output resample option couldn't be added. Looking at the README.md for directKiwi it seems installing scipy may be only necessary for OS X.
resample_poly() won't give you a precise resample to 6 kHz because of the Kiwi's funny 12001 Hz +/- sample rate and the fact that resample_poly() requires integer up/down interpolation/decimation factors. But hopefully this won't matter much to ARGO (some wav files coming from sound cards will have sample rate errors of a similar magnitude).
Thanks a bunch for the quick reply and additional info. I am looking at the directKiwi code, but after reading the blog, I know this is way over my DSP knowledge level. I was thinking I could just find a constant with a value of 12001 and change that to 6000. There, I just blabbed my DSP knowledge level to the whole world. Hi Hi. At least I think I understand the conversion issues better.
I found a command line program (sr-convert) which would be easy to work into a script, but it is not happy with the 12001 input rate. In looking at that code, I'm not sure if it would be easy to change from 12000 to 12001.
I'll keep looking, there's gotta be a suitable program around.
Thanks again and 73. Mike N8OOU.
So I actually have all the bits and pieces to do this (output file resampling for kiwirecorder). Let me try and whack something together..
Perhaps yu could try r8brain. https://www.voxengo.com/product/r8brain/
As per http://src.infinitewave.ca/ it performs really well. Batch processing can help in your job.
I use it for Sample rate error corrections an results are fine.
Best regards.
ANgazu.
You might have to use the batch utilities others are suggesting.
To answer Christoph, yes I am linux only here, with one exception for the US Tax prep program. Following your suggestion I find sox is installed as part of the Slackware distribution. It is a program I didn't know about, and in the google searches I looked at before writing this topic, it never came up. I can include it in my script and send the kiwirecorder file thru it to Argo.
Thanks to both of you for your help in this. I have a working solution at this point using sox. John, If you eventually add a rate parm for the kiwirecorder output file, I would alter my script to use it. I expect however, you have many other more important loose ends to chase. Thanks for giving it a quick go.
Again, thanks a lot for your assistance. I vote to close this topic.
Mike N8OOU.
Thanks for the link to R8brain. I called the page up and it looks like it would be a solution too.
Mike N8OOU
The following command resamples a wav file to 6000 Hz:
sox 20190124T151751Z_77000_iq.wav output.wav rate 6000
Thank you very much. I have downloaded and completed a few tests with the revised client code. So far the code has performed as documented. I am working to refine my script and when I think it is good to go, I will post why and how I am using this "feature". It may have some value to other users.
Thanks again for your attention and time spent to get this working.
Mike N8OOU 73.