GithubHelp home page GithubHelp logo

cytecbg / android-fskmodem Goto Github PK

View Code? Open in Web Editor NEW
70.0 15.0 24.0 952 KB

Android/Java library for encoding and decoding FSK audio signals.

License: GNU General Public License v3.0

Java 100.00%

android-fskmodem's Introduction

android-fskmodem

Android/Java library for encoding and decoding FSK audio signals.

The FSKModem library is developed by Cytec BG Ltd. as a free software available under the GNU GPLv3 license.

The FSKModem library consists of two major components:

  • FSKEncoder
  • FSKDecoder

It is designed to work with the existing implementation of SoftModem library for arduino.

For usage guidelines take a look at the examples.

android-fskmodem's People

Contributors

iganev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-fskmodem's Issues

Livre decode

Live decoding does not work between 2 devices. The capture by microphone worked only in the same handset

Having trouble decoding FSK signal

Hello there, many thanks for writing this library, it works very well on the wav sample you provide: https://github.com/cytecbg/android-fskmodem/blob/master/examples/FSKModemDecodeWav/assets/fsk.wav

But I tried to decode some other FSK signal (CallerID) which you can find the details here: http://matthieu.benoit.free.fr/cid_dsp.htm
and here: https://www.researchgate.net/publication/239926931_Caller_Line_Identity_Delivery_A_Computerized_Call_Alert_Application

The signal has the folowing properties

Transmission Scheme: 		Analog, phase-coherent FSK
Logical 1 (mark) 			1200 +/- 12 Hz
Logical 0 (space) 			2200 +/- 22 Hz
Transmission Rate: 			1200 bps

What I did was I added inside FSKConfig.java the signal properties

    public static final int CID_BELLCORE_FSK = 6;
    public static final int CID_BELLCORE_FSK_BAUD_RATE = 1225;
    public static final int CID_BELLCORE_FSK_LOW_FREQ = 2450; //Space
    public static final int CID_BELLCORE_FSK_HIGH_FREQ = 1225; //Mark

case CID_BELLCORE_FSK:

                this.modemBaudRate = CID_BELLCORE_FSK_BAUD_RATE;
                this.modemFreqLow = CID_BELLCORE_FSK_LOW_FREQ;
                this.modemFreqHigh = CID_BELLCORE_FSK_HIGH_FREQ;

                break;

then I inited my config like

 try {
            mConfig = new FSKConfig(FSKConfig.SAMPLE_RATE_44100, FSKConfig.PCM_8BIT, FSKConfig.CHANNELS_MONO, FSKConfig.CID_BELLCORE_FSK, FSKConfig.THRESHOLD_1P);
        } catch (IOException e1) {
            e1.printStackTrace();
        }

What was imidiatly wierd was why does the BAUD_RATE have to be 1225 and not 1200 (if its 1200 I get "Invalid sample rate or baudrate" exeption

also after listing all the frequency in calcFrequencyZerocrossing I discovered that I shold adjust mark from 1200 to 1225 and space from 2200 to 2450 because this 2 frequencies were most common in the file (also they are very close)

I also had to modify determineState function like this because if mark frequency is bigger then space on it did not detect hgih or low state properly

protected STATE determineState(int frequency, double rms) {

        STATE state = STATE.UNKNOWN;

        if (mConfig.modemFreqLow > mConfig.modemFreqHigh) //CID_SIG_V23 and CID_BELLCORE_FSK have Logical 0 (space) bigger frequency then Logical 1 (mark)
        {
            if (rms <= mConfig.rmsSilenceThreshold)
            {
                state = STATE.SILENCE;
            }
            else if (frequency > mConfig.modemFreqHighThresholdHigh && frequency <= mConfig.modemFreqLowThresholdHigh) //If frequency is between bigger and smaller frequency then we have a mark
            {
                state = STATE.LOW;
            }
            else if (frequency <= mConfig.modemFreqHighThresholdHigh)
            {
                state = STATE.HIGH;
            }
        }
        else //Other modem standards
        {
            if (rms <= mConfig.rmsSilenceThreshold)
            {
                state = STATE.SILENCE;
            }
            else if (frequency <= mConfig.modemFreqLowThresholdHigh) //If frequency is between bigger and smaller frequency then we have a mark
            {
                state = STATE.LOW;
            }
            else if (frequency <= mConfig.modemFreqHighThresholdHigh)
            {
                state = STATE.HIGH;
            }
        }

        return state;
    }

then it finaly started demodulating, but sadly the frame is wrong
I used this function to dump demodulated bytes to file

public static void WriteByteArrayToFile(byte[] byteArray, String filePath) {
        try {
            // Write the byte array to the file
            FileOutputStream fos = new FileOutputStream(filePath, true);
            fos.write(byteArray);
            fos.close();
        } catch (IOException ex) {
            System.out.println("An error occurred: " + ex.getMessage());
        }
    }

and this is what I got out of my sample:

F6 BE AFF F7 7D FF 7A F7 7B FF FB 7F D7 FE AF FFF

Now I would assume that the first byte should be message type (so 0x80 (MDMF) or 0x40 not 0xF6
the samples are here
https://www.mediafire.com/file/1otw9ien0u9iv1u/CID_sample-8.wav/file -- this is whole CallerID sample including Channel Seizure and Mark signal

https://www.mediafire.com/file/m8bvgmwzdqohqeu/fsk_only_no_cs-8.wav/file -- this is only FSK part

I also tried with this very simple sample: https://www.mediafire.com/file/r6nve95k5jduepm/fsk_10010110-8bit.wav/file
which only has 10010110 encoded in FSK but I still get only 0xFF 0xFF frame out, so I realy don't know anymore whats happening, is the baudrate I set in config the problem?

Hope you maybe have some idea, why even the simplest sample doesn't want to decode, because I am out of ideas, how to even debug this (I mean I know real world signals need filters, but this simple sample should be fine only using ZeroCrosing to figure out what 1 and what 0 is)

Thanks for Anwsering and Best Regards

Not working on Nexus 7

Thanks for writing this library. It seems to work very well on several devices I've tested, but it doesn't seem to work on a Nexus 7. While I hear the tone generation when triggering the encoding process, it doesn't seem to be detected on the Arduino side.

Is there something about configuring the AudioRecord to ensure it works on ASUS devices?

doubt on 16 bit modulation

First of all, thanks for the great work.
Meanwhile, I got a small doubt on the encoding part of the code

line 467 in FSKEncoder.java for 16 bit modulation:
buffer[i] = (short) (32767 * Math.sin((2 * Math.PI) * (i*1.0f / mConfig.sampleRate) * freq));

why there is no DC bias as what you did for the 8 bit modulation? As shown in line 449:
buffer[i] = (byte) (128 + 127 * Math.sin((2 * Math.PI) * (i*1.0f / mConfig.sampleRate) * freq));

not work for high frequencies

is it possible to configure for 17, 18, 19, 20 kHz? I was able to only make 12250 hz of higher values ​​stop working

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.