Skip to content

Commit

Permalink
Accomodation to high quality microphones
Browse files Browse the repository at this point in the history
Most of these changes are deseigned to accomodate high quality
recordings from microphones with greater dynamic range.
  • Loading branch information
towsey committed Sep 13, 2017
1 parent deb6028 commit 783e475
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,21 @@ public static Arguments Dev()
//string recordingPath = @"D:\SensorNetworks\WavFiles\BradLaw\PillagaForestSite18a\PILLIGA_20121125_052500.wav";
//string recordingPath = @"D:\SensorNetworks\WavFiles\BradLaw\PillagaForestSite18a\PILLIGA_20121125_194900.wav";
// next recording contains koala calls
string recordingPath = @"D:\SensorNetworks\WavFiles\BradLaw\WilliWilliNP_K48\Data\K48_20161104_211749.wav";
string outputPath = @"D:\SensorNetworks\Output\BradLawData\WilliWilliNP";
//string recordingPath = @"D:\SensorNetworks\WavFiles\BradLaw\WilliWilliNP_K48\Data\K48_20161104_211749.wav";
//string outputPath = @"D:\SensorNetworks\Output\BradLawData\WilliWilliNP";
//string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.AcousticHiRes.yml";

// Test recordings from Wildlife Acoustics demonstrating their compression algorithm
//string recordingPath = @"D:\SensorNetworks\WildLifeAcoustics\sm4_compression_demo\S4A00068_20160506_063000.wav";
string recordingPath = @"D:\SensorNetworks\WildLifeAcoustics\sm4_compression_demo\S4A00068_20160506_063000_new50.wav";
string outputPath = @"D:\SensorNetworks\Output\WildLifeAcoustics";
string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.AcousticHiRes.yml";

// Recording from Andrew Skeoch at Australian Wildlife Audio Recording Group
//string recordingPath = @"D:\SensorNetworks\WavFiles\BradLaw\TopTrapDam Pilliga 22050 16bit.wav";
//string outputPath = @"D:\SensorNetworks\Output\BradLawData\AWARG";
//string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.AcousticHiRes.yml";

// ARTIFICIAL TEST RECORDING
//string recordingPath = @"C:\SensorNetworks\WavFiles\TestRecordings\TEST_4min_artificial.wav";
//string outputPath = @"C:\SensorNetworks\Output\Test\Test2";
Expand Down
16 changes: 14 additions & 2 deletions AudioAnalysis/AnalysisPrograms/DrawLongDurationSpectrograms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,23 @@ public static Arguments Dev()
//var opdir = @"C:\SensorNetworks\Output\LSKiwi3\Test18May2017";

// PILLAGA FOREST RECORDINGS OF BRAD LAW - High Resolution analysis
string ipdir = @"D:\SensorNetworks\Output\BradLawData\WilliWilliNP\Towsey.Acoustic";
string opdir = @"D:\SensorNetworks\Output\BradLawData\WilliWilliNP";
//string ipdir = @"D:\SensorNetworks\Output\BradLawData\WilliWilliNP\Towsey.Acoustic";
//string opdir = @"D:\SensorNetworks\Output\BradLawData\WilliWilliNP";
//spectrogramConfigFile = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\SpectrogramConfigHiRes.yml";
//indexPropertiesFile = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\IndexPropertiesConfigHiRes.yml";

// USA WILD-LIFE ACOUSTICS TEST RECORDINGS OF LOSSY COMPRESSION - High Resolution analysis
string ipdir = @"D:\SensorNetworks\Output\WildLifeAcoustics\Towsey.Acoustic";
string opdir = @"D:\SensorNetworks\Output\WildLifeAcoustics";
spectrogramConfigFile = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\SpectrogramConfigHiRes.yml";
indexPropertiesFile = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\IndexPropertiesConfigHiRes.yml";

// Australian WILD-LIFE ACOUSTICS RECORDING Group - from Andrew Skeoch - High Resolution analysis
//string ipdir = @"D:\SensorNetworks\Output\BradLawData\AWARG\Towsey.Acoustic";
//string opdir = @"D:\SensorNetworks\Output\BradLawData\AWARG";
//spectrogramConfigFile = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\SpectrogramConfigHiRes.yml";
//indexPropertiesFile = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\IndexPropertiesConfigHiRes.yml";

return new Arguments
{
InputDataDirectory = new DirectoryInfo(ipdir),
Expand Down
30 changes: 19 additions & 11 deletions AudioAnalysis/AnalysisPrograms/Sandpit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void Dev(Arguments arguments)
int partialRowCount = rowsOfCsvFile.Count();
}

if (true)
if (false)
{
// The following are test methods to confirm that the frequency scale code is working
// They are also good tests for the making of standard sonograms.
Expand Down Expand Up @@ -490,27 +490,35 @@ public static void Dev(Arguments arguments)
ConcatenateIndexFiles.ConcatenateRibbonImages(dataDirs, match, outputDirectory, opFileStem, title, tidalInfo);
}

// Concatenate three images for Dan Stowell.
// Concatenate images horizontally or vertically.
if (false)
{
var imageDirectory = new DirectoryInfo(@"H:\Documents\SensorNetworks\MyPapers\2016_QMUL_SchoolMagazine");
string fileName1 = @"TNC_Musiamunat_20150702_BAR10__ACI-ENT-EVNCropped.png";
string fileName2 = @"GympieNP_20150701__ACI-ENT-EVN.png";
string fileName3 = @"Sturt-Mistletoe_20150702__ACI-ENT-EVN - Corrected.png";
// Concatenate three images for Dan Stowell.
//var imageDirectory = new DirectoryInfo(@"H:\Documents\SensorNetworks\MyPapers\2016_QMUL_SchoolMagazine");
//string fileName1 = @"TNC_Musiamunat_20150702_BAR10__ACI-ENT-EVNCropped.png";
//string fileName2 = @"GympieNP_20150701__ACI-ENT-EVN.png";
//string fileName3 = @"Sturt-Mistletoe_20150702__ACI-ENT-EVN - Corrected.png";
//string opFileName = string.Format("ThreeLongDurationSpectrograms.png");

// Concatenate two iimages for Paul Roe.
var imageDirectory = new DirectoryInfo(@"D:\SensorNetworks\Output\WildLifeAcoustics");
string fileName1 = @"S4A00068_20160506_063000__SummaryIndices.png";
string fileName2 = @"S4A00068_20160506_063000_new50__SummaryIndices.png";
string opFileName = string.Format("WildLifeAcoustics_TestLossyCompression3.png");

var image1Path = new FileInfo(Path.Combine(imageDirectory.FullName, fileName1));
var image2Path = new FileInfo(Path.Combine(imageDirectory.FullName, fileName2));
var image3Path = new FileInfo(Path.Combine(imageDirectory.FullName, fileName3));
//var image3Path = new FileInfo(Path.Combine(imageDirectory.FullName, fileName3));

var imageList = new List<Image>();

imageList.Add(Image.FromFile(image1Path.FullName));
imageList.Add(Image.FromFile(image2Path.FullName));
imageList.Add(Image.FromFile(image3Path.FullName));
//imageList.Add(Image.FromFile(image3Path.FullName));

Image combinedImage = ImageTools.CombineImagesVertically(imageList);
//var combinedImage = ImageTools.CombineImagesInLine(imageList);

string fileName = string.Format("ThreeLongDurationSpectrograms.png");
combinedImage.Save(Path.Combine(imageDirectory.FullName, fileName));
combinedImage.Save(Path.Combine(imageDirectory.FullName, opFileName));
}

// Concatenate two images but add labels for EcoCongress.
Expand Down
2 changes: 1 addition & 1 deletion AudioAnalysis/AudioAnalysisTools/Indices/IndexCalculate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static IndexCalculateResult Analysis(

// Deal with case where the signal waveform is continuous flat with values < 0.001. Has happened!!
// Although signal appears zero, this condition is required.
if (avgSignalEnvelope < 0.001)
if (avgSignalEnvelope < 0.0001)
{
Logger.Debug("Segment skipped because avSignalEnvelope is < 0.001!");
summaryIndices.ZeroSignal = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ public void LoadSpectrogramDictionary(Dictionary<string, double[,]> dictionary)
if (indexProperties.CalculateNormMax)
{
maxBound = this.IndexStats[key].GetValueOfNthPercentile(IndexDistributions.UpperPercentileDefault);

// correct for case where max bound = zero. This can happen where ICD is very short i.e. 0.1s.
if (maxBound < 0.0001)
{
maxBound = this.IndexStats[key].Maximum * 0.1;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion AudioAnalysis/TowseyLibrary/DataTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4711,7 +4711,7 @@ public static double[] filterMovingAverage(double[] signal, int width)

if (width >= length)
{
return null;
return signal;
}

if (length < 3)
Expand Down

0 comments on commit 783e475

Please sign in to comment.