/* Stores the signals with the provided coordinates. */ private void Fingerprint(string beaconMac, string gatewayMac, int Rssi) { /* If the received signal is not from the beacon to be used fingerprinting, ignore it */ if (!FingerprintingSettings.Fingerprinting_BeaconMacAddress.Equals(beaconMac)) { return; } /* Get gateway */ GatewayDao gwDao = new GatewayDao(); Gateway gateway = gwDao.GetGateway(gatewayMac); FingerprintingDao dao = new FingerprintingDao(); Fingerprinting fingerprinting = new Fingerprinting() { GatewayId = gateway.GatewayId, Rssi = Rssi, Timestamp = DateTime.Now, Xaxis = FingerprintingSettings.Fingerprinting_X, Yaxis = FingerprintingSettings.Fingerprinting_Y, EnvironmentId = FingerprintingSettings.Fingerprinting_EnvironmentId }; dao.NewFingerprint(fingerprinting); }
public void GetProminentFrequencies_Multiple_Frequencies(params int[] frequencies) { var sampleRate = 44100; var fftSize = 1024; var amplitude = 1; var frequencyIndices = Enumerable.Range(0, frequencies.Length); var sineWaves = frequencies .Select(frequency => Generate.Sinusoidal( sampleRate, sampleRate, frequency, amplitude) .ToList()); var samples = frequencyIndices .Select(index => sineWaves .Select(sineWave => sineWave[index]) .Sum()) .ToArray(); var prominentFrequencies = Fingerprinting.GetProminentFrequencies(samples, sampleRate); var expectedBins = frequencies.Select(frequency => FrequencyToBin(sampleRate, fftSize, frequency)); Assert.All(prominentFrequencies, actualBins => Assert.Equal(expectedBins, actualBins)); }
/* Adds new fingerprinting record */ public Fingerprinting NewFingerprint(Fingerprinting fingerprinting) { using (IndoorPositioningContext db = new IndoorPositioningContext()) { db.Fingerprintings.Add(fingerprinting); db.SaveChanges(); return(fingerprinting); } }
public void GetProminentFrequencies_Single_Frequency(int frequency) { var sampleRate = 44100; var fftSize = 1024; var amplitude = 1; var samples = Generate.Sinusoidal(sampleRate, sampleRate, frequency, amplitude); var prominentFrequencies = Fingerprinting.GetProminentFrequencies(samples, sampleRate); var expectedBin = FrequencyToBin(sampleRate, fftSize, frequency); var expectedBins = new[] { expectedBin }; Assert.All(prominentFrequencies, actualBins => Assert.Contains(expectedBin, actualBins)); Assert.All(prominentFrequencies, actualBins => Assert.Equal(expectedBins, actualBins)); }
static void Main(string[] args) { // Analyser.AnalysePcmFile(440, "../js/signals/440.pcm"); // Analyser.AnalyseGenerated(440); Fingerprinting.GetProminentFrequencies("../js/signals/almost-blue.pcm"); }