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