Second build sold out. Message will appear here when store is ready for third build ordering.

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

Comments

  • jksjks
    edited January 2019
    Christoph will have definitive answer for this I'm sure.

    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).
  • John,

    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.
  • jksjks
    edited January 2019
    I thought resample_poly() was vaguely familiar and I finally figured out why. I used it about a year ago when I was using Peter Monta's fantastic GNSS-DSP-tools (https://github.com/pmonta/GNSS-DSP-tools) to learn about Galileo and QZSS before I did the Kiwi implementation.

    So I actually have all the bits and pieces to do this (output file resampling for kiwirecorder). Let me try and whack something together..
  • @n8oou:
    • If you are on linux you can you sox to resample KiwiSDR wav files.
    • For kiwirecorder https://pypi.org/project/samplerate/ looks like a solution as it can handle audio streams, as opposed to working on recorded files after the recording is finished.
  • Hello.
    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.
  • I added a bunch of code. But now I'm finding that resample_poly() isn't being found in the scipi module for some reason. I don't understand because I don't recall having changed anything to my Python environment in the year since resample_poly() was last working. I have such trouble with Python sometimes and it's so frustrating because I don't know how to fix these issues.

    You might have to use the batch utilities others are suggesting.
  • John; Christoph;

    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.
  • ANgazu

    Thanks for the link to R8brain. I called the page up and it looks like it would be a solution too.

    Mike N8OOU
  • Try using a sample rate of 12000 rather than the odd Kiwi rate of 12001 if these programs complain. I bet it won't make much difference to ARGO. Converting from 12001 to 6000 is difficult unless the programs have a fractional resampler of some sort.
  • Here is a link to a manual for sox: sox.sourceforge.net/sox.html

    The following command resamples a wav file to 6000 Hz:
    sox 20190124T151751Z_77000_iq.wav output.wav rate 6000
    KA7U
  • jksjks
    edited January 2019
    Okay, I think kiwirecorder resampling works now. Update from https://github.com/jks-prv/kiwiclient.git (master or jks-v0.1 branch) and use the new "-r N" or "--resample N" option where N is the new sample rate in Hz. Works with regular and IQ-mode recordings. See the "resample" and "resample_iq" example targets in the Makefile.
    n8oou
  • John,

    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.
Sign In or Register to comment.