private void button_TO_READ_THE_AMPLITUDES_FILES_GENERATE_WAVS_Click(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("READS THE SINGLE COLUMNS GTAMPLITUDES FILES WITH COLUMN NAME Amplitudes and list large number of amplitudes data \r\n and \r\n fits with above durations milliseconds");
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "GTAMPS/GTAMPS Files (.GTAMPS)|*.GTAMPS|MONOAMPS/GTMONOAMPS Files (.GTMONOAMPS)|*.GTMONOAMPS|TXT/TXT_Files (.TXT)|*.TXT|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_gtmidiamps_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
double total_durations_in_milliseconds = Convert.ToDouble(this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text.TrimEnd().TrimStart().Trim());
int int_duration_in_millisecond = (int)total_durations_in_milliseconds;
// this is auto calculated from the samples available and durations
//c
// Replace "your-audio-file.wav" with the path to your .wav file
/// string gtmidiampsforwavs = ___temp_gtmidiamps_files_name;// "your-audio-file.wav";
///
// this function is in same file public class WaveFileWriter : Stream
//seperate public static class is defined there
PUBLIC_STATIC_CLASS_SAAN_WAVE_FILES_WRITER
.public_static_void_read_saan_styles_amplitude_text_file__to_float_Array_and_durations_and_generate_mono_channel_wav_files___Main
(
___temp_gtmidiamps_files_name
,
___temp_gtmidiamps_files_name+"_saanS_MONO.wav"
,
int_duration_in_millisecond
);
System.Windows.Forms.MessageBox.Show("done ___temp_gtmidiamps_files_name = " + ___temp_gtmidiamps_files_name);
}//private void button_TO_READ_THE_AMPLITUDES_FILES_GENERATE_WAVS_Click(object sender, EventArgs e)
public static void public_static_void_read_saan_styles_amplitude_text_file__to_float_Array_and_durations_and_generate_mono_channel_wav_files___Main(string inputFilePath_for_amplitudes, string outputFilePath, int int_durationMilliseconds)
{
// string inputFilePath = "path_to_your_input_file.txt";
// string outputFilePath = "path_to_your_output_file.wav";
// int durationMilliseconds = 33838; // Example duration in milliseconds
// Read amplitude values from the file
float[] amplitudes = ReadAmplitudesFromFile___SAAN_STYLES(inputFilePath_for_amplitudes);
// Normalize amplitudes and this is the real important thing which reads the amplitudes and calculates necessary things in detail
// Normalize amplitudes and this is the real important thing which reads the amplitudes and calculates necessary things in detail
// Normalize amplitudes and this is the real important thing which reads the amplitudes and calculates necessary things in detail
float[] normalizedAmplitudes = NormalizeAmplitudes___FROM_FLOAT_ARRAY___RETURNS___FLOAT__ARRAY(amplitudes, inputFilePath_for_amplitudes);
/// to do this in seperate button public static List<float[]> NormalizeAmplitudes___FROM_LIST_OF_FLOAT_ARRAY___RETURNS___lIST_OF_NORMALIZED_FLOAT__ARRAY(List<float[]> list_of_float_arrays_for_several_channels___amplitudes, string file_of_the_GTAMPS_PATH)
/// to do this in seperate button public static List<float[]> NormalizeAmplitudes___FROM_LIST_OF_FLOAT_ARRAY___RETURNS___lIST_OF_NORMALIZED_FLOAT__ARRAY(List<float[]> list_of_float_arrays_for_several_channels___amplitudes, string file_of_the_GTAMPS_PATH)
////// to do this in seperate button public static List<float[]> NormalizeAmplitudes___FROM_LIST_OF_FLOAT_ARRAY___RETURNS___lIST_OF_NORMALIZED_FLOAT__ARRAY(List<float[]> list_of_float_arrays_for_several_channels___amplitudes, string file_of_the_GTAMPS_PATH)
// Normalize amplitudes and this is the real important thing which reads the amplitudes and calculates necessary things in detail
// Normalize amplitudes and this is the real important thing which reads the amplitudes and calculates necessary things in detail
// Normalize amplitudes and this is the real important thing which reads the amplitudes and calculates necessary things in detail
//PUBLIC_STATIC_DOUBLE___WAV_FILES_AMPLITUDE_GENERATOR_SAMPLES_PER_SECOND_FOUND this is auto calculated
//so samples rate is not important
// Calculate sample rate based on the specified duration
int sampleRate = (int)(normalizedAmplitudes.Length / (int_durationMilliseconds / 1000.0));
double ___fractional_data_samples_rate = (normalizedAmplitudes.Length / (int_durationMilliseconds / 1000.0));
// Create a mono PCM WAV file
/// CreateWavFile___FROM_THE_SAAN_STYLES_AMPLITUDE_FILES(outputFilePath.Replace(".wav","")+"_sps_"+ sampleRate+"_actual_sps_"+ Math.Round(___fractional_data_samples_rate,3) + "_durs_"+ ( (int)(int_durationMilliseconds/1000))+".wav" , normalizedAmplitudes, sampleRate, ___fractional_data_samples_rate);
CreateWavFile___FROM_THE_SAAN_STYLES_AMPLITUDE_FILES(outputFilePath.Replace(".wav", "") + "_sps_" + sampleRate + "_actual_sps_" + Math.Round(___fractional_data_samples_rate, 3) + "_durs_" + (Math.Round( ( (double)int_durationMilliseconds / 1000),3) )+ ".wav", normalizedAmplitudes, sampleRate, ___fractional_data_samples_rate);
}//public static void public_static_void_read_saan_styles_amplitude_text_file__to_float_Array_and_durations_and_generate_mono_channel_wav_files___Main(string inputFilePath_for_amplitudes , string outputFilePath , int int_durationMilliseconds )
private void button___READ_THE_STEREO_AMPLITUDES_FILES_GENERATE_WAVS_Click(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("READS THE STEREO MULTIPLE COLS GTAMPLITUDES FILES WITH COLUMN NAME Amplitudes and list large number of amplitudes data \r\n and \r\n fits with above durations milliseconds");
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "STEREOAMPS/STEREOAMPS Files (.STEREOAMPS)|*.STEREOAMPS|TXT/TXT_Files (.TXT)|*.TXT|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_gtmidiamps_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
double total_durations_in_milliseconds = Convert.ToDouble(this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text.TrimEnd().TrimStart().Trim());
int int_duration_in_millisecond = (int)total_durations_in_milliseconds;
// Replace "your-audio-file.wav" with the path to your .wav file
/// string gtmidiampsforwavs = ___temp_gtmidiamps_files_name;// "your-audio-file.wav";
///
// this function is in same file public class WaveFileWriter : Stream
//seperate public static class is defined there
PUBLIC_STATIC_CLASS_SAAN_WAVE_FILES_WRITER
.GenerateStereoWavFilesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS
(
___temp_gtmidiamps_files_name
,
___temp_gtmidiamps_files_name + "_saan_STEREO.wav"
,
int_duration_in_millisecond
);
}
public static void GenerateStereoWavFilesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS(string inputFilePath, string outputFilePath, int durationMilliseconds)
{
// Read amplitude values from the file
float[,] amplitudes = ReadAmplitudesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS(inputFilePath);
// to do List<float[]> ___list_of_float_array_if_several_columns_found_in_data
// to do ReadAmplitudesFromFile___SEVERAL_CHANNELS___SAAN_STYLES(inputFilePath_for_amplitudes);
// Normalize amplitudes for each channel
float[,] normalizedAmplitudes = NormalizeAmplitudes___for_stereo_channel_cases(amplitudes);
// Calculate sample rate based on the specified duration
int sampleRate = (int)(normalizedAmplitudes.GetLength(0) / (durationMilliseconds / 1000.0));
// Create a stereo PCM WAV file
CreateStereoWavFile(outputFilePath, normalizedAmplitudes, sampleRate);
}//public static void GenerateStereoWavFilesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS(string inputFilePath, string outputFilePath, int durationMilliseconds)
public static float[,] ReadAmplitudesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS(string filePath)
{
string[] lines = File.ReadAllLines(filePath);
int rowCount = lines.Length;
int colCount = lines[0].Split(',').Length;//predicts from the first row
float[,] amplitudes = new float[rowCount, colCount];
for (int i = 0; i < rowCount; i++)
{
string[] values = lines[i].Split(',');
for (int j = 0; j < colCount; j++)
{
//for each cols
if (float.TryParse(values[j], out float amplitude))
{
amplitudes[i, j] = amplitude;
}//if (float.TryParse(values[j], out float amplitude))
}//for (int j = 0; j < colCount; j++)
}//for (int i = 0; i < rowCount; i++)
return amplitudes;
}//public static float[,] ReadAmplitudesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS(string filePath)
public static void CreateWavFile___with_several_channels_data_in_list_of_floating_point_arrays(string filePath, List<float[]> channelAmplitudes_several_channels_several_columns, int number_of_channels_found, int sampleRate)
{
int numChannels = number_of_channels_found;//channelAmplitudes.Count;
using (WaveFileWriter writer = new WaveFileWriter(filePath, new WaveFormat(sampleRate, numChannels)))
{
int numSamples = channelAmplitudes_several_channels_several_columns[0].Length;
for (int i = 0; i < numSamples; i++)
{
for (int channel = 0; channel < numChannels; channel++)
{
float amplitude = channelAmplitudes_several_channels_several_columns[channel][i];
short sampleValue = (short)(amplitude * short.MaxValue);
byte[] sampleBytes = BitConverter.GetBytes(sampleValue);
writer.Write(sampleBytes, 0, sampleBytes.Length);
}//for (int channel = 0; channel < numChannels; channel++)
}//for (int i = 0; i < numSamples; i++)
}//using (WaveFileWriter writer = new WaveFileWriter(filePath, new WaveFormat(sampleRate, numChannels)))
}//public static void CreateWavFile___with_several_channels_data_in_list_of_floating_point_arrays(string filePath, List<float[]> channelAmplitudes_several_channels_several_columns, int sampleRate)
private void button_DUMP_WAV_TO_CHANNEL_AMPLITUDES_Click(object sender, EventArgs e)
{
///dls files to samples dumps
///C:\Program Files (x86)\Extreme Sample Converter 3
///D:\SAANSWAVESDSPS\NWaves\SAANSWAVESDSPS\too important exsc_3.6.1_demo
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "wav/wav Files (.wav)|*.wav|GTWAVS/GTWAVS_Files (.wave)|*.wave|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_waves_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
if (this.textBox_BIT_DEPTH.Text.ToString().TrimEnd().TrimStart().Trim().Length > 0)
{
try
{
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
=
Convert.ToInt16(this.textBox_BIT_DEPTH.Text.ToString().TrimEnd().TrimStart().Trim());
}
catch (Exception _to_convert)
{
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
= 16;//default
}//catch(Exception _to_convert)
}
else
{
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
= 16;//default
}//else cases if(this.textBox_BIT_DEPTH.Text.ToString().TrimEnd().TrimStart().Trim().Length>0)
// tested ok
PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS
.INDEPENDENT_ExtractAndWriteChannelAmplitudes
(___temp_waves_files_name);
////////////////////////////////////////////////////////////////////////////////////////////////
this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS
.Text
=
ExcelFormulaParser_GT_PARSER
.GT_PARSERS
.public_static_class_simulations_CONTROLLER_for_gt_Class
.PUBLIC_STATIC_DOUBLE___WAV_FILES_AMPLITUDE_GENERATOR_DURATIONS_MILLISECONDS_FOUND
.ToString();
////////////////////////////////////////////////////////////////////////////////////////////////
System.Windows.Forms.MessageBox.Show("Channel wise Amplitudes dumped in .GTAMPS files");
}//private void button_DUMP_WAV_TO_CHANNEL_AMPLITUDES_Click(object sender, EventArgs e)
public static void INDEPENDENT_ExtractAndWriteChannelAmplitudes(string inputFilePath)
{
StringBuilder ___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
= new StringBuilder();
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.Clear();
string string___do_you_need_detailed_report_log = "NO";
//////using Microsoft.VisualBasic;
//////string input = Interaction.InputBox("Prompt", "Title", "Default", -1, -1);
//what_to_search_text_substring = Microsoft.VisualBasic.VBCodeProvider.InputBox()
string___do_you_need_detailed_report_log = Microsoft.VisualBasic.Interaction.InputBox("DO YOU NEED DETAILED REPORT LOG (YES/NO)", "NO","NO");
string___do_you_need_detailed_report_log
= string___do_you_need_detailed_report_log.TrimEnd().TrimStart().Trim().ToUpper();
if( string___do_you_need_detailed_report_log.Contains("YES"))
{
System.Windows.Forms.MessageBox.Show("IT WILL TAKE LONG TIME AND WILL GENERATE HEAVY LOG FILE FOR DATA ANALYSIS ");
}//if( string___do_you_need_detailed_report_log.Contains("YES"))
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
"channel,sample_counter,found_in_wav_files___sampleRate___bit_depth_taken,found_the_millisecond,symmetry_of_amplitudes(-1 to +1) waves conventions"
);
double ___temp_max_milliseconds_from_every_channels = 0;
double ___temp_samples_count_for_this_channel = 0;
double ___temp_duration_found_for_this_channel = 0;
double ___temp_samples_count_found_till_now_in_current_channel = 0;
double ___temp_mins_fouund = 0;
double ___temp_secs_found = 0;
// (___temp_duration_found_for_this_channel / 60000) + "_mins" +
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
int channels = 0;
int sampleRate = 0;
// Read WAV header to get channels and sample rate
INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
for (int channel = 0; channel < channels; channel++)
{
___temp_samples_count_for_this_channel = 0;
___temp_duration_found_for_this_channel = 0;
___temp_mins_fouund = 0;
___temp_secs_found = 0;
// (___temp_duration_found_for_this_channel / 60000) + "_mins" +
// Create a separate text file for each channel
//////string outputFilePath = $"{Path.GetFileNameWithoutExtension(inputFilePath)}_channel{channel + 1}.txt";
///
string outputFilePath
=
//////System.IO.Directory.
//////Path.GetFileNameWithoutExtension(inputFilePath)
//////+"_channel_"+ (channel +1) +".txt";
inputFilePath + "_ch_" + (channel + 1) +"sps_"+ sampleRate + ".GTAMPS";// ".txt";
using (StreamWriter writer = new StreamWriter(outputFilePath))
{
// Write the heading to the file
writer.WriteLine("Amplitudes,default int bytesPerSample = 2; // Assuming 16-bit samples");
// Read and write amplitude values for the current channel
int bytesPerSample = 2; // Assuming 16-bit samples
if (
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
%8==0
)
{
bytesPerSample
=
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
/ 8; // two bytes is 8 bits
}
////// if (
////// ExcelFormulaParser_GT_PARSER
//////.SAANAUDS
//////.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
//////.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
//////% 8 == 0
//////)
else
{
bytesPerSample
=
(int)
(
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
/ 8)
;
}// else of
////// if (
////// ExcelFormulaParser_GT_PARSER
//////.SAANAUDS
//////.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
//////.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
//////% 8 == 0
//////)
System.Windows.Forms.MessageBox.Show
("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
// Write amplitude value to the text file
// writer.WriteLine(amplitude);
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
/// writer.WriteLine(amplitude.ToString("F38"));
writer.WriteLine(amplitude.ToString("F8")); /// float type is 32 bit and it can support upto this
// writer.Write( ",");
// writer.Write( (Convert.ToDouble(amplitude) ) .ToString("G27"));
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
//////////////////////////////////////___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
//////////////////////////////////////.AppendLine
//////////////////////////////////////(
//////////////////////////////////////"channel,sample_counter,bit_depth_taken,found_the_millisecond,symmetry_of_amplitudes(-1 to +1) waves conventions"
//////////////////////////////////////);
///
//////for references ___temp_samples_count_for_this_channel = 0;
//////for references ___temp_duration_found_for_this_channel = 0;
___temp_max_milliseconds_from_every_channels
= Math.Max(___temp_max_milliseconds_from_every_channels, ___temp_duration_found_for_this_channel);
___temp_duration_found_for_this_channel
=
___temp_samples_count_for_this_channel / sampleRate;
___temp_mins_fouund =
(int)
( ___temp_duration_found_for_this_channel
/ 60000);
___temp_secs_found =
(int)(___temp_duration_found_for_this_channel / 1000)
-
(___temp_mins_fouund * 60);
if(string___do_you_need_detailed_report_log.Contains("YES"))
{
//inputFilePath + "_ch_" + (channel + 1) +"sps_"+ sampleRate + ".GTAMPS";// ".txt";
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
// (channel + 1) +","+ ___temp_samples_count_for_this_channel + ",read_sps(*8)= "+ ( bytesPerSample * 8 )+"," + ___temp_mins_fouund + "_mins and " + ___temp_secs_found + " real ms= " + ___temp_duration_found_for_this_channel.ToString("F6") + "," + amplitude.ToString("F6")
(channel + 1) + "," + ___temp_samples_count_for_this_channel + ",read_sps(*8)= " + (bytesPerSample * 8) + "," + ((___temp_duration_found_for_this_channel * 1000).ToString("F6")) + "," + amplitude.ToString("F6")
);
}
else
{
}// if(string___do_you_need_detailed_report_log.Contains("YES"))
}//while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
}//using (StreamWriter writer = new StreamWriter(outputFilePath))
/// no need for this Console.WriteLine($"Channel {channel + 1} amplitudes written to: {outputFilePath}");
///
___temp_duration_found_for_this_channel
=
___temp_samples_count_for_this_channel / sampleRate;
System.Windows.Forms.MessageBox.Show(" for channel = " + channel + " samples= " + ___temp_samples_count_for_this_channel + " durations= " + ___temp_mins_fouund + "_mins and " + ___temp_secs_found + " real_ms= " + ___temp_duration_found_for_this_channel);
}//for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
/////////////////////////////////////////////////////////////// wav files handles with milliseconds instead of micro seconds //////
ExcelFormulaParser_GT_PARSER
.GT_PARSERS
.public_static_class_simulations_CONTROLLER_for_gt_Class
.PUBLIC_STATIC_DOUBLE___WAV_FILES_AMPLITUDE_GENERATOR_DURATIONS_MILLISECONDS_FOUND
=
___temp_max_milliseconds_from_every_channels * 1000;
/////////////////////////////////////////////////////////////// wav files handles with milliseconds instead of micro seconds //////
if (string___do_you_need_detailed_report_log.Contains("YES"))
{
System.IO.File.WriteAllText
(
inputFilePath + "_det_report_not_import_this_is_csv_likes.log"
,
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.ToString()
);
}
else
{
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
"no data accumulated you asked for NO"
);
System.IO.File.WriteAllText
(
inputFilePath + "_det_report_not_import_this_is_csv_likes.log"
,
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.ToString()
);
}// else case of if (string___do_you_need_detailed_report_log.Contains("YES"))
}//public static void INDEPENDENT_ExtractAndWriteChannelAmplitudes(string inputFilePath)
public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
{
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
sampleRate = binaryReader.ReadInt32();
}// public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
private void button_GTWAVS_OPEN_WAV_FILES_Click(object sender, EventArgs e)
{
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "wav/wav Files (.wav)|*.wav|GTWAVS/GTWAVS_Files (.wave)|*.wave|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_waves_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
//////PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS
////// .INDEPENDENT_ExtractAndWriteChannelAmplitudes
////// (___temp_waves_files_name);
// Replace "your-audio-file.wav" with the path to your .wav file
string audioFilePath = ___temp_waves_files_name;// "your-audio-file.wav";
// Create a WaveFileReader to read the audio file
using (var waveReader = new SAANAUDS.Wave.WaveFileReader(audioFilePath))
{
/// this SAANAUDS.Wave.WaveFileReader dumps the data to text
// this.waveViewer_FOR_GTWAVS.WaveStream = (SAANAUDS.Wave.WaveStream)waveReader.SAAN_Wav_Streams;// this.generatorPanel_GT_WAV_SIGNAL
// this.waveViewer_FOR_GTWAVS.Invalidate();
// Create a WaveOutEvent to play the audio
this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text = waveReader.TotalTime.TotalMilliseconds.ToString();
System.Windows.Forms.MessageBox.Show("for big files part takes lot of times using (var waveReader = new SAANAUDS.Wave.WaveFileReader(audioFilePath))");
/// nothing happens and hangs
//////using (var waveOut = new SAANAUDS.Wave.WaveOutEvent())
////// {
////// // Set the desired WaveFormat (e.g., 16-bit PCM with 44.1kHz sample rate)
////// waveOut.Init(new SAANAUDS.Wave.WaveChannel32(waveReader));
////// // Start playing the audio
////// // Console.WriteLine("Press Enter to start playing...");
////// // Console.ReadLine();
////// waveOut.Play();
////// // Wait for the user to press Enter again to stop playing
////// // Console.WriteLine("Press Enter to stop playing...");
////// // Console.ReadLine();
////// }//using (var waveOut = new WaveOutEvent())
///
}//using (var waveReader = new WaveFileReader(audioFilePath))
//////System.Windows.Forms.MessageBox.Show(" part complete ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER done");
//////PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS
//////.ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER
//////(audioFilePath);
}//private void button_GTWAVS_OPEN_WAV_FILES_Click(object sender, EventArgs e)
private void button_TO_CONVERT_TEXT_OR_CSV_TO_WAV_FILES_Click(object sender, EventArgs e)
{
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "txt/txt Files (.txt)|*.txt|CSV/CSV_Files (.CSV)|*.CSV|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_txt_or_csv_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
System.Windows.Forms.MessageBox.Show("Reads sorted_channel,sorted_sample_counter,unnormalized_amplitude,(optional)unnormalized_decibel");
// txt_files_names
//////private void buttonSave_Click(object sender, EventArgs e)
////// {
////// btnStop_Click(this, e);
////// var sfd = new SaveFileDialog();
////// sfd.Filter = "WAV File|*.wav";
////// if (sfd.ShowDialog() == DialogResult.OK)
////// {
////// var osp = new OffsetSampleProvider(wg);
////// osp.TakeSamples = wg.WaveFormat.SampleRate * 20 * wg.WaveFormat.Channels;
////// WaveFileWriter.CreateWaveFile16(sfd.FileName, osp);
////// }// if (sfd.ShowDialog() == DialogResult.OK)
////// }// private void buttonSave_Click(object sender, EventArgs e)
// Replace "your-audio-file.wav" with the path to your .wav file
string audioFilePath = ___temp_txt_or_csv_files_name + "_saan_converts.wav";// "your-audio-file.wav";
double converted_durs = 0;
try
{
converted_durs
=
Convert.ToDouble(this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text.ToString().TrimEnd().TrimStart().Trim());
converted_durs = (int)Math.Floor(converted_durs / 1000);
}
catch (Exception _excp_to_convert)
{
}//catch(Exception _excp_to_convert)
double _durations_millis = Math.Min(100, converted_durs);
/// SAANAUDS.Wave.PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
try
{
//////var osp = new OffsetSampleProvider(wg);
//////osp.TakeSamples = wg.WaveFormat.SampleRate * 20 * wg.WaveFormat.Channels;
//////WaveFileWriter.CreateWaveFile16(sfd.FileName, osp);
/// SAANAUDS.Wave.WaveFileWriter _wavswriter = new SAANAUDS.Wave.WaveFileWriter();
//////_wavswriter.
//////READ_CHANNEL_SAMPLES_NUMBER_AMPLITUDES_UNNORMALIZED_FROM_TXT_FILES(audioFilePath, _durations_millis);
//////SAANAUDS.Wave.WaveFileWriter
////// .READ_CHANNEL_SAMPLES_NUMBER_AMPLITUDES_UNNORMALIZED_FROM_TXT_FILES(audioFilePath, _durations_millis);
// Task.Run(async () => await WriteWavFileFromList(txt_files_names + "_saan_converts.wav", waveFormat)).Wait();
int num_channels = 2;//default
int bit_depth = 16;//default
int samples_rate = 44100;//default///autocalculates
int durations_millis = 60000;//default
string _str_bit_wavs_durations_found = "";
_str_bit_wavs_durations_found = this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text.ToString().TrimEnd().TrimStart().Trim();
try
{
durations_millis = Convert.ToInt32(_str_bit_wavs_durations_found);
}
catch (Exception _excp_convertions_exception)
{
durations_millis = 60000;
}//catch(Exception _excp_convertions_exception)
string ___str_bit_depth = "";
___str_bit_depth = this.textBox_BIT_DEPTH.Text.ToString().TrimEnd().TrimStart().Trim();
try
{
bit_depth = Convert.ToInt32(___str_bit_depth);
}
catch (Exception _excp_convertions_exception)
{
bit_depth = 16;
}//catch(Exception _excp_convertions_exception)
string _str_channel_count = "";
_str_channel_count = this.textBox_CHANNEL_COUNTS.ToString().TrimEnd().TrimStart().Trim();
try
{
num_channels = Convert.ToInt32(_str_channel_count);
}
catch (Exception _excp_convertions_exception)
{
num_channels = 2;
}//catch(Exception _excp_convertions_exception)
int sampleRate = SAANAUDS.Wave.WaveFileWriter
.CalculateSamplesPerSecond___SAAN
(
durations_millis
,
num_channels
,
bit_depth
);
//////////////trying specially here with BufferedWaveProvider ___temp_buffered_wav_provider
///
////// BufferedWaveProvider ___temp_buffered_wav_provider
Task.Run(
async () => await
SAANAUDS.Wave.WaveFileWriter
.THE___Main______GENERATE_WAV_FILE_FROM_TEXT_CSV_WITH_AMPLITUDES____RAW_DATA_WITHOUT_API
(
___temp_txt_or_csv_files_name
,
___temp_txt_or_csv_files_name + "_SAAN_WITHOUT_API.WAV"
,
(ushort)num_channels
,
(uint)sampleRate
,
(ushort)bit_depth
)
).Wait();
System.Windows.Forms.MessageBox.Show("done THE___Main______GENERATE_WAV_FILE_FROM_TEXT_CSV_WITH_AMPLITUDES____RAW_DATA_WITHOUT_API");
//////public static async Task THE___Main______GENERATE_WAV_FILE_FROM_TEXT_CSV_WITH_AMPLITUDES____RAW_DATA_WITHOUT_API
////// (
////// string csvFilePath
////// ,
////// string wavesFilePath
////// ,
////// ushort numChannels
////// ,
////// uint sampleRate
////// ,
////// ushort bitsPerSample
////// )
Task.Run(
async () => await
SAANAUDS.Wave.WaveFileWriter
.Main_FUNCTION_TO_READ_LARGE_TEXT_DATA_WITH_ALL_PROCESSORS(___temp_txt_or_csv_files_name)
).Wait();
System.Windows.Forms.MessageBox.Show("Counting stages done processors data done");
string filename_csvtxt = "";
//////int num_channels = 2;
//////int bit_depth = 16;
//////int samples_rate = 44100;
//////int durations_millis = 60000;
Task.Run(
async () => await
SAANAUDS.Wave.WaveFileWriter
.ReadTOO_LARGE_OVER_110_MBS_File___line_to_line_and_generate_wav
(
filename_csvtxt
,
num_channels
,
bit_depth
,
samples_rate
,
durations_millis
)
).Wait();
System.Windows.Forms.MessageBox.Show("First stages done");
Task.Run(
async () => await
SAANAUDS.Wave.WaveFileWriter
.READ_CHANNEL_SAMPLES_NUMBER_AMPLITUDES_UNNORMALIZED_FROM_TXT_FILES(___temp_txt_or_csv_files_name, _durations_millis)
).Wait();
}
catch (Exception _excp_wav_files_writer_constructions)
{
System.Windows.Forms.MessageBox.Show("_excp_wav_files_writer_constructions " + _excp_wav_files_writer_constructions.Message + _excp_wav_files_writer_constructions.StackTrace.ToString());
}//catch(Exception _excp_wav_files_writer_constructions)
}//private void button_TO_CONVERT_TEXT_OR_CSV_TO_WAV_FILES_Click(object sender, EventArgs e)
public static async Task THE___Main______GENERATE_WAV_FILE_FROM_TEXT_CSV_WITH_AMPLITUDES____RAW_DATA_WITHOUT_API
(
string csvFilePath
,
string wavesFilePath
,
ushort numChannels
,
uint sampleRate
,
ushort bitsPerSample
)
{
string inputCsvFilePath = csvFilePath;//"output.csv"; // Path to the CSV file
string outputWavFilePath = wavesFilePath;//"output.wav"; // Path for the output WAV file
try
{
//////// Read the CSV file data
//////byte[] audioData = ReadCsvToAudioData______RAW_DATA_WITHOUT_API
////// (
////// inputCsvFilePath
////// );
// Read the CSV file data
float[] audioData = ReadCsvToAudioData______RAW_DATA_WITHOUT_API___FLOATS_ARRAY
(
inputCsvFilePath
);
// Create the WAV file from the audio data
// CreateWavFileFromAudioData______RAW_DATA_WITHOUT_API(audioData, outputWavFilePath);
////// public static async Task CreateWavFileFromAudioData______RAW_DATA_WITHOUT_API
//////(
//////byte[] audioData
//////,
//////string wavFilePath
//////,
//////ushort numChannels
//////,
//////uint sampleRate = 44100
//////,
//////ushort bitsPerSample = 16
//////)
Task.Run(
async () => await
SAANAUDS.Wave.WaveFileWriter
.
///CreateWavFileFromAudioData______RAW_DATA_WITHOUT_API
CreateWavFileFromAudioData______float_array_audiodata___RAW_DATA_WITHOUT_API
(
audioData
,
outputWavFilePath
,
numChannels
,
sampleRate
,
bitsPerSample
)
).Wait();
/// Console.WriteLine($"WAV file saved to {outputWavFilePath}");
///
System.Windows.Forms.MessageBox.Show($"WAV file saved to {outputWavFilePath}");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
System.Windows.Forms.MessageBox.Show("An error occurred: " + ex.Message + " " + ex.StackTrace.ToString());
}
}// public static async Task THE___Main______GENERATE_WAV_FILE_FROM_TEXT_CSV_WITH_AMPLITUDES____RAW_DATA_WITHOUT_API(string csvFilePath, string wavesFilePath)
//////public static async Task THE___Main______GENERATE_WAV_FILE_FROM_TEXT_CSV_WITH_AMPLITUDES____RAW_DATA_WITHOUT_API
////// (
////// string csvFilePath
////// ,
////// string wavesFilePath
////// ,
////// ushort numChannels
////// ,
////// uint sampleRate
////// ,
////// ushort bitsPerSample
private void button_SAAN_SYLLABLES_TO_AMPLITUDES_SAMPLES_Click(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("reads the comma seperated files with first cols as lysylls and second columns as durs ms these are .SAANLYRSYLLS or .csv or .txt");
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "SAANLYRSYLLS/SAANLYRSYLLS Files (.SAANLYRSYLLS)|*.SAANLYRSYLLS|TXT/TXT (.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___saan_temp_lyrsylls_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
SAAGIRID.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019.initialize_dxf_for_sbuilder_for_dxf();
SAANAUDS.Wave
.ConstructIrregularConvexClosedPolygonSmoothe_rollable_with_initial_ordered_counterclock_sequential_edge_lengths_list
.public_static_void_read_lyrs_file_to_iterate_find_smoothe_polygon
(
___saan_temp_lyrsylls_files_name
,
1000
,
50
);
//////////////////////////////////////////////////////////////////////////////////////////
this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text
=
SAANAUDS.Wave
.ConstructIrregularConvexClosedPolygonSmoothe_rollable_with_initial_ordered_counterclock_sequential_edge_lengths_list
.___initial_total_duration_found_in_lyrs_sylls_files
.ToString()
;
//////////////////////////////////////////////////////////////////////////////////////////
SAAGIRID.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019.finalizer_dxf_for_sbuilder_for_dxf();
//////////////////////////////////////////////////////////////////////////////////////////
System.IO.File.WriteAllText
(
___saan_temp_lyrsylls_files_name+"_"+System.DateTime.Now.ToString("MMddyyyyhhmmss")+"_rolled.dxf"
,
SAAGIRID.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.sbuilder_for_dxf.ToString()
);
//////////////////////////////////////////////////////////////////////////////////////////
System.Windows.Forms.MessageBox.Show("images saved data saved and ultimately wioll generate .GTAMPS");
//////////////////////////////////////////////////////////////////////////////////////////
}// private void button_SAAN_SYLLABLES_TO_AMPLITUDES_SAMPLES_Click(object sender, EventArgs e)
private void button___READ_THE_STEREO_AMPLITUDES_FILES_GENERATE_WAVS_Click(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("READS THE STEREO MULTIPLE COLS GTAMPLITUDES FILES WITH COLUMN NAME Amplitudes and list large number of amplitudes data \r\n and \r\n fits with above durations milliseconds");
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "STEREOAMPS/STEREOAMPS Files (.STEREOAMPS)|*.STEREOAMPS|TXT/TXT_Files (.TXT)|*.TXT|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_gtmidiamps_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
double total_durations_in_milliseconds = Convert.ToDouble(this.textBox_FOR_TXT_TO_WAVS_DURATIONS_MILLI_SECS.Text.TrimEnd().TrimStart().Trim());
int int_duration_in_millisecond = (int)total_durations_in_milliseconds;
// Replace "your-audio-file.wav" with the path to your .wav file
/// string gtmidiampsforwavs = ___temp_gtmidiamps_files_name;// "your-audio-file.wav";
///
// this function is in same file public class WaveFileWriter : Stream
//seperate public static class is defined there
PUBLIC_STATIC_CLASS_SAAN_WAVE_FILES_WRITER
.GenerateStereoWavFilesFromCSV___FOR___MULTIPLE_COLUMNS_AMPLITUDES_FOR_STEREO_CHANNELS
(
___temp_gtmidiamps_files_name
,
___temp_gtmidiamps_files_name + "_saan_STEREO.wav"
,
int_duration_in_millisecond
);
}
private void button_WAV_FILES_TO_DATA_BANK_ASCII_Click(object sender, EventArgs e)
{
///dls files to samples dumps
///C:\Program Files (x86)\Extreme Sample Converter 3
///D:\SAANSWAVESDSPS\NWaves\SAANSWAVESDSPS\too important exsc_3.6.1_demo
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.Filter = "wav/wav Files (.wav)|*.wav|GTWAVS/GTWAVS_Files (.wave)|*.wave|All Files (*.*)|*.*";
openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.ShowDialog();
string ___temp_waves_files_name = openFileDialog_FOR_SEVERAL_PURPOSES_FOR_MIDI_FILES.FileName.Replace("\\", "\\\\");
string folderPath_FOR_WAV_BANKS = Path.GetDirectoryName(___temp_waves_files_name);
SAAGIRID.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019.initialize_dxf_for_sbuilder_for_dxf();
System.IO.File.WriteAllText
(
folderPath_FOR_WAV_BANKS + "\\within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"
,
/// "\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
"\r\nwriting_all_text______inside______________button_WAV_FILES_TO_DATA_BANK_ASCII_Click to clear previous contents in this file\r\n"
);
///for references
////////////___internal_stringbuilder_for_small_rows_appending
//////////// .AppendLine
//////////// (
//////////// $"" +
//////////// $",{___temp_samples_count_for_this_channel}" +
//////////// $",{amplitude.ToString("F6")}"
//////////// );
System.IO.File.WriteAllText
(
folderPath_FOR_WAV_BANKS + "\\simplest_csv_like_data.txt"
,
/// "\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
"\r\nwriting_all_text______inside______________button_WAV_FILES_TO_DATA_BANK_ASCII_Click to clear previous contents in this file\r\n"
+"filename,sample_count,amplitude_float\r\n"
);
SAANAUDS
.Wave.
PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS
.READ_ALL_WAV_FILES_IN_SOUNDSBANK_FOLDER_TO_REPORT_SAMPLES_DATA___Main
(
folderPath_FOR_WAV_BANKS
,
ref this.progressBarFOR_ANIMATIONS_SAVING
)
;
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.finalizer_dxf_for_sbuilder_for_dxf();
System.IO.File.WriteAllText
(
folderPath_FOR_WAV_BANKS
+ "\\reporting_complete_selected_waves_data.dxf"
,
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.sbuilder_for_dxf
.ToString()
);
System.Windows.Forms.MessageBox.Show("sounds banks data ASCII_Fied");
}//private void button_WAV_FILES_TO_DATA_BANK_ASCII_Click(object sender, EventArgs e)
public static void READ_ALL_WAV_FILES_IN_SOUNDSBANK_FOLDER_TO_REPORT_SAMPLES_DATA___Main(string directoryPath_FOR_SAMPLES_WAVE_BANK_WAVE_FILES, ref System.Windows.Forms.ProgressBar ___report_progressbar)
{
string directoryPath = directoryPath_FOR_SAMPLES_WAVE_BANK_WAVE_FILES;//"your_directory_path_here";
ProcessAllWavFiles___FOR_SOUNDS_BANK_DATA_DUMPING(directoryPath , ref ___report_progressbar);
}//public static void READ_ALL_WAV_FILES_IN_SOUNDSBANK_FOLDER_TO_REPORT_SAMPLES_DATA___Main(STRING directoryPath_FOR_SAMPLES_WAVE_BANK_WAVE_FILES)
public static void ProcessAllWavFiles___FOR_SOUNDS_BANK_DATA_DUMPING(string directoryPath,ref System.Windows.Forms.ProgressBar ___report_progressBar)
{
string[] wavFiles = Directory.GetFiles(directoryPath, "*.wav");
StringBuilder finalOutput_STRINGSBUILDER = new StringBuilder();
int ___numbers_of_wav_files_processed = 0;
___report_progressBar.Maximum = wavFiles.Length + 3;
___report_progressBar.Value = ___numbers_of_wav_files_processed;
___report_progressBar.Invalidate();
___report_progressBar.Refresh();
foreach (string wavFile in wavFiles)
{
___report_progressBar.Value = ___numbers_of_wav_files_processed;
___report_progressBar.Invalidate();
___report_progressBar.Refresh();
ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(wavFile, ref finalOutput_STRINGSBUILDER, directoryPath);
___numbers_of_wav_files_processed++;
}// foreach (string wavFile in wavFiles)
// ___report_progressBar.Maximum = wavFiles.Length + 3;
___report_progressBar.Value = ___report_progressBar.Maximum;//
// Write the collected information to a single text file
File.WriteAllText(Path.Combine(directoryPath, "SAAN_SOUNDS_BANKS_COMPILED_output.txt"), finalOutput_STRINGSBUILDER.ToString());
}//public static void ProcessAllWavFiles___FOR_SOUNDS_BANK_DATA_DUMPING(string directoryPath)
public static void ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(string inputFilePath,ref StringBuilder finalOutput_STRINGSBUILDER,string folder_path)
{
int channels = 0;
int sampleRate = 0;
StringBuilder ___internal_stringbuilder_for_direct_files_appending = new StringBuilder();
___internal_stringbuilder_for_direct_files_appending.Clear();
___internal_stringbuilder_for_direct_files_appending
.AppendLine("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated ");
StringBuilder ___internal_stringbuilder_for_small_rows_appending = new StringBuilder();
___internal_stringbuilder_for_small_rows_appending.Clear();
//////////////////////////////////////////////////////////////////////////////////////////////////////////
___internal_stringbuilder_for_small_rows_appending
.AppendLine
(
inputFilePath+",,,,"
);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
///
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;/// RESETS THE X FOR NEW FILES
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y =
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+ 3000;/// INCREASES THE Y 3000 UPWARDS FOR NEW FILES READING STARTS
PUBLIC_STATIC_INT_FILE_COUNTER++;
PUBLIC_STATIC_STRING_CURRENT_FILES_NAME = inputFilePath;
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_ON_FRONT_VIEW_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
0
,
300
,
"FILESNAMES"
,
PUBLIC_STATIC_INT_FILE_COUNTER.ToString() + " " + PUBLIC_STATIC_STRING_CURRENT_FILES_NAME
,
"XDATA_CHECKING"
,
PUBLIC_STATIC_INT_FILE_COUNTER ^ 250
)
;
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
for (int channel = 0; channel < channels; channel++)
{
int bytesPerSample = 2; // Assuming 16-bit samples
//////if (ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS % 8 == 0)
//////{
////// bytesPerSample = ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8;
//////}
//////else
//////{
////// bytesPerSample = (int)(ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8);
//////}
/// FOR SOUNDS BANKS WE WILL NOT SAY THIS System.Windows.Forms.MessageBox.Show("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
double ___temp_samples_count_for_this_channel = 0;
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
//////finalOutput_STRINGSBUILDER.AppendLine("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
//////finalOutput_STRINGSBUILDER.AppendLine($"{Path.GetFileName(inputFilePath)},{___temp_samples_count_for_this_channel},{sampleRate},{amplitude.ToString("F6")}");
___internal_stringbuilder_for_direct_files_appending
.AppendLine($"{channel},{sampleRate}" +
$",{Path.GetFileName(inputFilePath)}" +
$",{___temp_samples_count_for_this_channel}" +
$",{sampleRate}" +
$",{amplitude.ToString("F6")}");
___internal_stringbuilder_for_small_rows_appending
.AppendLine
(
$"" +
$",{___temp_samples_count_for_this_channel}" +
$",{amplitude.ToString("F6")}"
);
/// FOR REFERENCES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;/// RESETS THE X FOR NEW FILES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y =
/// FOR REFERENCES ////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
/// FOR REFERENCES ////// + 3000;/// INCREASES THE Y 3000 UPWARDS FOR NEW FILES READING STARTS
/// FOR REFERENCES
///
//////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
////// =
////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X + 10;
/// FOR EACH SAMPLES IT INCREASES X TO 10 UNITS
/// WE WILL NOT CHANGE THIS PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_line_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
,
0
,
"layer_mods_250_amplitudes_" + (Math.Abs((double)amplitude) * 100000 % 250).ToString()
,
"xdata_checking"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
-
(___temp_samples_count_for_this_channel.ToString().Length) * 6
-30
,
0
,
90
,
6
,
"bottom_text"
,
___temp_samples_count_for_this_channel.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
+
300* (Math.Sign((double)amplitude))
,
0
,
90
,
6
,
"bottom_text"
, amplitude.ToString("F6")
.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
/////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
}// while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
////// WE CAN DO THE ANALYSIS ON THE ACCUMULATED DATA FOR THE CURRENT OBJECTS OF AMPLITUDES AND THE CONDITIONS OF THE SLOPE CHANGES LISTS
///THESE KIND OF ANALYSIS IS MORE DETAILED KIND OF DATA HANDLING AND ANALYSIS ON THE WAV FILES TO GET MORE INFORMATIONS FOR TOPOLOGY LEVEL UNDERSTANDINGS
///THESE WILL GIVE US THE POWER TO DO ABSTRACT CHANGES ON THE SEQUENCES OF THE OBJECTS AND THERE ARE OPPERTUNITIES TO CHANGE THE MOODS WITH SOME RANGES OF WITHIN RANGE CHANGES
System.IO.File.AppendAllText
(
folder_path + "\\within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"
,
"\r\n"+ ___internal_stringbuilder_for_direct_files_appending.ToString()
);
/////////////////////////////////////////////////////////////////////////////////////////////
System.IO.File.AppendAllText
(
folder_path + "\\simplest_csv_like_data.txt"
,
___internal_stringbuilder_for_small_rows_appending.ToString()
/// "\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
);
}// for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
}//public static void ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(string inputFilePath, StringBuilder finalOutput_STRINGSBUILDER)
//calling convention PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS.INDEPENDENT_ExtractAndWriteChannelAmplitudes
public static void INDEPENDENT_ExtractAndWriteChannelAmplitudes(string inputFilePath)
{
StringBuilder ___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
= new StringBuilder();
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.Clear();
string string___do_you_need_detailed_report_log = "NO";
//////using Microsoft.VisualBasic;
//////string input = Interaction.InputBox("Prompt", "Title", "Default", -1, -1);
//what_to_search_text_substring = Microsoft.VisualBasic.VBCodeProvider.InputBox()
string___do_you_need_detailed_report_log = Microsoft.VisualBasic.Interaction.InputBox("DO YOU NEED DETAILED REPORT LOG (YES/NO)", "NO","NO");
string___do_you_need_detailed_report_log
= string___do_you_need_detailed_report_log.TrimEnd().TrimStart().Trim().ToUpper();
if( string___do_you_need_detailed_report_log.Contains("YES"))
{
System.Windows.Forms.MessageBox.Show("IT WILL TAKE LONG TIME AND WILL GENERATE HEAVY LOG FILE FOR DATA ANALYSIS ");
}//if( string___do_you_need_detailed_report_log.Contains("YES"))
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
"channel,sample_counter,found_in_wav_files___sampleRate___bit_depth_taken,found_the_millisecond,symmetry_of_amplitudes(-1 to +1) waves conventions"
);
double ___temp_max_milliseconds_from_every_channels = 0;
double ___temp_samples_count_for_this_channel = 0;
double ___temp_duration_found_for_this_channel = 0;
double ___temp_samples_count_found_till_now_in_current_channel = 0;
double ___temp_mins_fouund = 0;
double ___temp_secs_found = 0;
// (___temp_duration_found_for_this_channel / 60000) + "_mins" +
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
int channels = 0;
int sampleRate = 0;
// Read WAV header to get channels and sample rate
INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
for (int channel = 0; channel < channels; channel++)
{
___temp_samples_count_for_this_channel = 0;
___temp_duration_found_for_this_channel = 0;
___temp_mins_fouund = 0;
___temp_secs_found = 0;
// (___temp_duration_found_for_this_channel / 60000) + "_mins" +
// Create a separate text file for each channel
//////string outputFilePath = $"{Path.GetFileNameWithoutExtension(inputFilePath)}_channel{channel + 1}.txt";
///
string outputFilePath
=
//////System.IO.Directory.
//////Path.GetFileNameWithoutExtension(inputFilePath)
//////+"_channel_"+ (channel +1) +".txt";
inputFilePath + "_ch_" + (channel + 1) +"sps_"+ sampleRate + ".GTAMPS";// ".txt";
using (StreamWriter writer = new StreamWriter(outputFilePath))
{
// Write the heading to the file
writer.WriteLine("Amplitudes,default int bytesPerSample = 2; // Assuming 16-bit samples");
// Read and write amplitude values for the current channel
int bytesPerSample = 2; // Assuming 16-bit samples
if (
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
%8==0
)
{
bytesPerSample
=
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
/ 8; // two bytes is 8 bits
}
////// if (
////// ExcelFormulaParser_GT_PARSER
//////.SAANAUDS
//////.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
//////.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
//////% 8 == 0
//////)
else
{
bytesPerSample
=
(int)
(
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
/ 8)
;
}// else of
////// if (
////// ExcelFormulaParser_GT_PARSER
//////.SAANAUDS
//////.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
//////.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
//////% 8 == 0
//////)
System.Windows.Forms.MessageBox.Show
("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
// Write amplitude value to the text file
// writer.WriteLine(amplitude);
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
/// writer.WriteLine(amplitude.ToString("F38"));
writer.WriteLine(amplitude.ToString("F8")); /// float type is 32 bit and it can support upto this
// writer.Write( ",");
// writer.Write( (Convert.ToDouble(amplitude) ) .ToString("G27"));
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
//////////////////////////////////////___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
//////////////////////////////////////.AppendLine
//////////////////////////////////////(
//////////////////////////////////////"channel,sample_counter,bit_depth_taken,found_the_millisecond,symmetry_of_amplitudes(-1 to +1) waves conventions"
//////////////////////////////////////);
///
//////for references ___temp_samples_count_for_this_channel = 0;
//////for references ___temp_duration_found_for_this_channel = 0;
___temp_max_milliseconds_from_every_channels
= Math.Max(___temp_max_milliseconds_from_every_channels, ___temp_duration_found_for_this_channel);
___temp_duration_found_for_this_channel
=
___temp_samples_count_for_this_channel / sampleRate;
___temp_mins_fouund =
(int)
( ___temp_duration_found_for_this_channel
/ 60000);
___temp_secs_found =
(int)(___temp_duration_found_for_this_channel / 1000)
-
(___temp_mins_fouund * 60);
if(string___do_you_need_detailed_report_log.Contains("YES"))
{
//inputFilePath + "_ch_" + (channel + 1) +"sps_"+ sampleRate + ".GTAMPS";// ".txt";
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
// (channel + 1) +","+ ___temp_samples_count_for_this_channel + ",read_sps(*8)= "+ ( bytesPerSample * 8 )+"," + ___temp_mins_fouund + "_mins and " + ___temp_secs_found + " real ms= " + ___temp_duration_found_for_this_channel.ToString("F6") + "," + amplitude.ToString("F6")
(channel + 1) + "," + ___temp_samples_count_for_this_channel + ",read_sps(*8)= " + (bytesPerSample * 8) + "," + ((___temp_duration_found_for_this_channel * 1000).ToString("F6")) + "," + amplitude.ToString("F6")
);
}
else
{
}// if(string___do_you_need_detailed_report_log.Contains("YES"))
}//while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
}//using (StreamWriter writer = new StreamWriter(outputFilePath))
/// no need for this Console.WriteLine($"Channel {channel + 1} amplitudes written to: {outputFilePath}");
///
___temp_duration_found_for_this_channel
=
___temp_samples_count_for_this_channel / sampleRate;
System.Windows.Forms.MessageBox.Show(" for channel = " + channel + " samples= " + ___temp_samples_count_for_this_channel + " durations= " + ___temp_mins_fouund + "_mins and " + ___temp_secs_found + " real_ms= " + ___temp_duration_found_for_this_channel);
}//for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
/////////////////////////////////////////////////////////////// wav files handles with milliseconds instead of micro seconds //////
ExcelFormulaParser_GT_PARSER
.GT_PARSERS
.public_static_class_simulations_CONTROLLER_for_gt_Class
.PUBLIC_STATIC_DOUBLE___WAV_FILES_AMPLITUDE_GENERATOR_DURATIONS_MILLISECONDS_FOUND
=
___temp_max_milliseconds_from_every_channels * 1000;
/////////////////////////////////////////////////////////////// wav files handles with milliseconds instead of micro seconds //////
if (string___do_you_need_detailed_report_log.Contains("YES"))
{
System.IO.File.WriteAllText
(
inputFilePath + "_det_report_not_import_this_is_csv_likes.log"
,
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.ToString()
);
}
else
{
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
"no data accumulated you asked for NO"
);
System.IO.File.WriteAllText
(
inputFilePath + "_det_report_not_import_this_is_csv_likes.log"
,
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.ToString()
);
}// else case of if (string___do_you_need_detailed_report_log.Contains("YES"))
}//public static void INDEPENDENT_ExtractAndWriteChannelAmplitudes(string inputFilePath)
public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
{
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
sampleRate = binaryReader.ReadInt32();
}// public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static void PUBLIC_STATIC_VOID_INDEPENDENT_READ_SINGLE_WAV_FILE_TO_CONVERT_ITS_REPORT_TO_DXF(string inputFilePath, ref ProgressBar progressbar)
{
StringBuilder ___internal_stringbuilder_for_direct_files_appending = new StringBuilder();
___internal_stringbuilder_for_direct_files_appending.Clear();
StringBuilder ___internal_stringbuilder_for_small_rows_appending = new StringBuilder();
___internal_stringbuilder_for_small_rows_appending.Clear();
string folder_path= Path.GetDirectoryName(inputFilePath);
int sampleRate = 44100;
/// int[] channels = { };
// short[] channels = { };
int channels = 0;
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
/// INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
// // // public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
// // // {
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
sampleRate = binaryReader.ReadInt32();
////////////// }// public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
for (int channel = 0; channel < channels; channel++)
{
int bytesPerSample = 2; // Assuming 16-bit samples
//////if (ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS % 8 == 0)
//////{
////// bytesPerSample = ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8;
//////}
//////else
//////{
////// bytesPerSample = (int)(ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8);
//////}
/// FOR SOUNDS BANKS WE WILL NOT SAY THIS System.Windows.Forms.MessageBox.Show("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
double ___temp_samples_count_for_this_channel = 0;
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
//////finalOutput_STRINGSBUILDER.AppendLine("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
//////finalOutput_STRINGSBUILDER.AppendLine($"{Path.GetFileName(inputFilePath)},{___temp_samples_count_for_this_channel},{sampleRate},{amplitude.ToString("F6")}");
___internal_stringbuilder_for_direct_files_appending
.AppendLine($"{channel},{sampleRate}" +
$",{Path.GetFileName(inputFilePath)}" +
$",{___temp_samples_count_for_this_channel}" +
$",{sampleRate}" +
$",{amplitude.ToString("F6")}");
___internal_stringbuilder_for_small_rows_appending
.AppendLine
(
$"" +
$",{___temp_samples_count_for_this_channel}" +
$",{amplitude.ToString("F6")}"
);
/// FOR REFERENCES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;/// RESETS THE X FOR NEW FILES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y =
/// FOR REFERENCES ////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
/// FOR REFERENCES ////// + 3000;/// INCREASES THE Y 3000 UPWARDS FOR NEW FILES READING STARTS
/// FOR REFERENCES
///
//////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
////// =
////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X + 10;
/// FOR EACH SAMPLES IT INCREASES X TO 10 UNITS
/// WE WILL NOT CHANGE THIS PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_line_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
,
0
,
"layer_mods_250_amplitudes_" + (Math.Abs((double)amplitude) * 100000 % 250).ToString()
,
"xdata_checking"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
-
(___temp_samples_count_for_this_channel.ToString().Length) * 6
- 30
,
0
,
90
,
6
,
"bottom_text"
,
___temp_samples_count_for_this_channel.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
+
300 * (Math.Sign((double)amplitude))
,
0
,
90
,
6
,
"bottom_text"
, amplitude.ToString("F6")
.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
/////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
}// while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
////// WE CAN DO THE ANALYSIS ON THE ACCUMULATED DATA FOR THE CURRENT OBJECTS OF AMPLITUDES AND THE CONDITIONS OF THE SLOPE CHANGES LISTS
///THESE KIND OF ANALYSIS IS MORE DETAILED KIND OF DATA HANDLING AND ANALYSIS ON THE WAV FILES TO GET MORE INFORMATIONS FOR TOPOLOGY LEVEL UNDERSTANDINGS
///THESE WILL GIVE US THE POWER TO DO ABSTRACT CHANGES ON THE SEQUENCES OF THE OBJECTS AND THERE ARE OPPERTUNITIES TO CHANGE THE MOODS WITH SOME RANGES OF WITHIN RANGE CHANGES
System.IO.File.AppendAllText
(
folder_path + "\\within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"
,
"\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
);
/////////////////////////////////////////////////////////////////////////////////////////////
System.IO.File.AppendAllText
(
folder_path + "\\simplest_csv_like_data.txt"
,
___internal_stringbuilder_for_small_rows_appending.ToString()
/// "\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
);
}// for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
}//public static void PUBLIC_STATIC_VOID_INDEPENDENT_READ_SINGLE_WAV_FILE_TO_CONVERT_ITS_REPORT_TO_DXF(string inputFilePath, ref progressbar)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static int public_static_int_channels = 1;
public static int public_static_int_sampleRate = 30;
public static string folder_path = "";// Path.GetDirectoryName(inputFilePath);
public static int public_static_int_bytes_per_sample = 2;
public static double public_static_x_shift_for_circular_rendering_for_amplitudes = 0;
public static double public_static_y_shift_for_circular_rendering_for_amplitudes = 30000;
public static double public_static_double___total_durations_in_milliseconds_from_the_samples_rate_and_header_data_for_wave_files = 3;///milliseconds
public static int PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA = 3;//public static async Task FindDataSection(BinaryReader binaryReader)
public static double PUBLIC_STATIC_DOUBLE_TOTAL_SAMPLES_IN_WAV_FILE = 3;
public static double PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING = 1.1;
public static double public_static_double_angle = 0;// i * angleIncrement; // Angle for the current sample
public static double public_static_double_radius = 0;// RToPlot + circlePlotScale; // Radius of the circle for the current sample
public static double public_static_double_radials_x = 0;// radius * Math.Cos(angle * Math.PI / 180); // X coordinate
public static double public_static_double_radials_y = 0;// radius * Math.Sin(angle * Math.PI / 180); // Y coordinate
public static double public_static_double_RToPlot = 3000;
public static double public_static_double_circlePlotScale = 1;
/// RToPlot + circlePlotScale; // Radius of the circle for the current sample
/// int bytesPerSample = 2; // Bytes per sample (16-bit)
/// int samplesPerSecond = 44100; // Sample rate (samples per second)
/// int channelCount = 2; // Number of channels
/// string filePath = "example.wav"; // Path to the WAV file
// Get the file size in bytes
/// long fileSizeInBytes = new FileInfo(filePath).Length;
// Calculate the duration in milliseconds
/// double durationInSeconds = (double)fileSizeInBytes / (bytesPerSample * channelCount * samplesPerSecond);
/// double durationInMilliseconds = durationInSeconds * 1000;
public static async Task ReadSingleWavFileToConvertItsReportToDxf(string inputFilePath, IProgress<int> progress)
{
const int bytesPerSample = 2; // Assuming 16-bit samples
const int bufferSize = 1024 * 1024; // 1MB buffer size
folder_path= Path.GetDirectoryName(inputFilePath);
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, FileOptions.Asynchronous))
{
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.initialize_dxf_for_sbuilder_for_dxf();
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
// int channels, sampleRate;
int dummy_channel_number = 0;
int dummy_sampleRate = 30;
//////////////////////////////////////////////////////////////////////////////////////////////////
/// await ReadWaveHeader(binaryReader, dummy_channel_number, dummy_sampleRate);
await ReadWaveHeader(inputFilePath);
/// await FindDataSection(binaryReader);/// called inside ReadWaveHeader
//////////////////////////////////////////////////////////////////////////////////////////////////
var tasks = new List<Task>();
for (int channel = 0; channel < public_static_int_channels; channel++)
{
tasks.Add(ReadChannelData(folder_path,inputFilePath, binaryReader, channel, bytesPerSample, public_static_int_sampleRate, progress));
}//for (int channel = 0; channel < channels; channel++)
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
await Task.WhenAll(tasks);
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}//using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, FileOptions.Asynchronous))
}//public static async Task ReadSingleWavFileToConvertItsReportToDxf(string inputFilePath, IProgress<int> progress)
// Function to find the start of the "data" section in the WAV file
public static async Task FindDataSection(BinaryReader binaryReader)
{
int headerSize = 0;
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
{
string chunkID = new string(binaryReader.ReadChars(4));
int chunkSize = binaryReader.ReadInt32();
if (chunkID == "data")
{
// Found the start of the "data" section
binaryReader.BaseStream.Seek(-8, SeekOrigin.Current); // Move back to the beginning of the chunk
break;
}
else
{
// Skip to the next chunk
binaryReader.BaseStream.Seek(chunkSize, SeekOrigin.Current);
headerSize += 8 + chunkSize; // Update the total header size
}// if (chunkID == "data")
}//while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA = Math.Min(44,headerSize);
/// return headerSize;
}//public static async Task FindDataSection(BinaryReader binaryReader)
// public static async Task ReadWaveHeader(BinaryReader binaryReader, out int public_static_int_channels, out int sampleRate)
//////public static async Task ReadWaveHeader(BinaryReader binaryReader, int local_channel_non_static, int local_sample_rate_data_which_is_non_static)
//////{
////// binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
////// public_static_int_channels = binaryReader.ReadInt16();// this is global data for this class
////// binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
////// public_static_int_sampleRate = binaryReader.ReadInt32();// this is global data for this class
//////}//public static async Task ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
/// <summary>
///
///
///
///
///
/// </summary>
/// <param name="folder_path"></param>
/// <param name="inputFilePath"></param>
/// <param name="binaryReader"></param>
/// <param name="channel"></param>
/// <param name="bytesPerSample"></param>
/// <param name="public_static_int_sampleRate"></param>
/// <param name="progress"></param>
/// <returns></returns>
public static async Task ReadWaveHeader(string filePath)
{
//////// Get the file size in bytes
long fileSizeInBytes = new FileInfo(filePath).Length;
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
//////////////////////////////////////////////////////
///it gets waiting and not getting proper values within times otherwise ok await FindDataSection(binaryReader);
//////////////////////////////////////////////////////
///
///
int headerSize = 0;
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
{
string chunkID = new string(binaryReader.ReadChars(4));
int chunkSize = binaryReader.ReadInt32();
if (chunkID == "data")
{
// Found the start of the "data" section
binaryReader.BaseStream.Seek(-8, SeekOrigin.Current); // Move back to the beginning of the chunk
// break;
goto goto_here_when_headerSize_found;
}
else
{
// Skip to the next chunk
binaryReader.BaseStream.Seek(chunkSize, SeekOrigin.Current);
headerSize += 8 + chunkSize; // Update the total header size
}//else of if (chunkID == "data")
}//while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
goto_here_when_headerSize_found:;
PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA = Math.Min(44, headerSize);
//////binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
//////int channels = binaryReader.ReadInt16();
//////binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
//////int sampleRate = binaryReader.ReadInt32();
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
int channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
int sampleRate = binaryReader.ReadInt32();
binaryReader.BaseStream.Seek(34, SeekOrigin.Begin); // Move to the 'BitsPerSample' field
int bytesPerSample = binaryReader.ReadInt16() / 8; // Convert bits per sample to bytes per sample
// Do something with the retrieved channel count and sample rate
// For example, you can assign them to local variables or update global variables
int local_channel_non_static = channels;
public_static_int_channels = channels;
/// int local_sample_rate_data_which_is_non_static = sampleRate;
public_static_int_sampleRate = sampleRate;
public_static_int_bytes_per_sample = bytesPerSample;
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using SAANAUDS.FileFormats.Wav;
using System.Threading.Tasks;
using System.Linq;
using System.Windows.Forms;
//////using System.Windows.Controls;
namespace SAANAUDS.Wave
{
/// <summary>This class supports the reading of WAV files,
/// providing a repositionable WaveStream that returns the raw data
/// contained in the WAV file
/// </summary>
public class WaveFileReader : WaveStream
{
private readonly WaveFormat waveFormat;
private readonly bool ownInput;
private readonly long dataPosition;
private readonly long dataChunkLength;
private readonly List<RiffChunk> chunks = new List<RiffChunk>();
private readonly object lockObject = new object();
private Stream waveStream;
/// ///in c sharp byte is 8 bit
/// ///in c sharp byte is 8 bit
/// /// ///in c sharp byte is 8 bit
/// /// ///in c sharp short is 16 bit
/// /// ///in c sharp int is 32 bit
/// /// ///in c sharp long is 64 bit
/// /// ///in c sharp float is 32 bit
/// /// ///in c sharp double is 64 bit
/// /// ///in c sharp decimal is 128 bit
/// /// ///in c sharp char is 16 bit
/// /// ///in c sharp bool is 8 bit
public Stream SAAN_Wav_Streams;
public int SAAN_FINDS_WAV_HEADER_SIZE = 0;
public string saan_waves_filesnames = "";
public StringBuilder PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER = null;
public List<PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL> PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL;
//////async Task SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES(string wavFilePath ,int data_position_start,int sampleRate,int channels,int bitsPerSample)
////// {
////// try
////// {
////// using (FileStream fs = new FileStream(wavFilePath, FileMode.Open, FileAccess.Read))
////// {
////// // Skip the WAV header (44 bytes)
////// /// fs.Seek(44, SeekOrigin.Begin);
////// //data_position_start
////// fs.Seek(data_position_start, SeekOrigin.Begin);
////// // Read format information
////// //////int sampleRate = 44100; // Given in the prompt
////// //////int channels = 2; // Given in the prompt
////// //////int bitsPerSample = 16; // Given in the prompt
////// int bytesPerSample = bitsPerSample / 8;
////// // Read and process samples
////// int sampleCounter = 0;
////// byte[] buffer = new byte[bytesPerSample * channels];
////// int bytesRead;
////// while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
////// {
////// for (int i = 0; i<bytesRead; i += bytesPerSample)
////// {
////// short sample = BitConverter.ToInt16(buffer, i);
////// double amplitude = Math.Abs(sample) / (double)(short.MaxValue);
////// double decibel = 20 * Math.Log10(amplitude);
////// // Console.WriteLine($"Sample {sampleCounter}: Amplitude = {amplitude:0.000}, Decibel = {decibel:0.00}");
////// //////PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
////// ////// .AppendLine
////// ////// ("Sample {sampleCounter}: Amplitude = {amplitude:0.000}, Decibel = {decibel:0.00}");
////// PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
////// .AppendLine
////// (sampleCounter + "," + amplitude + " , " + decibel );
////// sampleCounter++;
////// }
////// }
////// }
////// }
////// catch (Exception ex)
////// {
////// // Console.WriteLine("Error reading WAV file: {0}", ex.Message);
////// PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
////// .AppendLine("Error reading WAV file: {0}" + ex.Message + " " + ex.StackTrace.ToString());
////// }
////// }// public void SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES()
async Task SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES(string wavFilePath, int data_position_start, int sampleRate, int channels, int bitsPerSample)
{
try
{
/// ///in c sharp byte is 8 bit
/// ///in c sharp byte is 8 bit
/// /// ///in c sharp byte is 8 bit
/// /// ///in c sharp short is 16 bit
/// /// ///in c sharp int is 32 bit
/// /// ///in c sharp long is 64 bit
/// /// ///in c sharp float is 32 bit
/// /// ///in c sharp double is 64 bit
/// /// ///in c sharp decimal is 128 bit
/// /// ///in c sharp char is 16 bit
/// /// ///in c sharp bool is 8 bit
///
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
.AppendLine("channel,sample_counter,normalized_amplitude,normalized_decibel");
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
= new List<PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL>();
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.Clear();
using (FileStream fs = new FileStream(wavFilePath, FileMode.Open, FileAccess.Read))
{
// Skip the WAV header (44 bytes)
fs.Seek(data_position_start, SeekOrigin.Begin);
// Read format information
int bytesPerSample = bitsPerSample / 8;
// Read and process samples
// int sampleCounter = 0;
double sampleCounter = 0;
byte[] buffer = new byte[bytesPerSample * channels];
int bytesRead;
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
{
for (int i = 0; i < bytesRead; i += bytesPerSample * channels)
{
for (int channel = 0; channel < channels; channel++)
{
short sample = BitConverter.ToInt16(buffer, i + bytesPerSample * channel);
double amplitude = Math.Abs(sample) / (double)(short.MaxValue);
double decibel = 20 * Math.Log10(amplitude);
PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
_temp_data______PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL =
new PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL();
_temp_data______PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.CHANNEL_NUMBER = channel;
_temp_data______PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.SAMPLE_COUNTER = sampleCounter;
_temp_data______PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.AMPLITUDE_NORMALIZED = amplitude;
_temp_data______PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.DECIBEL = decibel;
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.Add(_temp_data______PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
.AppendLine($"{channel + 1},{sampleCounter},{amplitude},{decibel}");
sampleCounter++;
}// for (int channel = 0; channel < channels; channel++)
}// for (int i = 0; i < bytesRead; i += bytesPerSample * channels)
}// while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
}// using (FileStream fs = new FileStream(wavFilePath, FileMode.Open, FileAccess.Read))
///////////////////////////////////////////
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
=
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.OrderBy(PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL => PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL.CHANNEL_NUMBER)
.ThenBy(PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL => PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL.SAMPLE_COUNTER)
.ToList();
///////////////////////////////////////////
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
.AppendLine("sorted_channel,sorted_sample_counter,normalized_amplitude,normalized_decibel");
//////double amplitude = Math.Abs(sample) / (double)(short.MaxValue);
//////double decibel = 20 * Math.Log10(amplitude);
foreach (PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL _samples_data in PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL)
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
.AppendLine
(
_samples_data.CHANNEL_NUMBER
+" , "+
_samples_data.SAMPLE_COUNTER
+ " , " +
_samples_data.AMPLITUDE_NORMALIZED
+ " , " +
_samples_data.DECIBEL
);
}//foreach(PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL _samples_data in PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL)
}
catch (Exception ex)
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER
.AppendLine("Error reading WAV file: {0}" + ex.Message + " " + ex.StackTrace.ToString());
}
}/// async Task SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES(string wavFilePath, int data_position_start, int sampleRate, int channels, int bitsPerSample)
async Task SAAN_REPORT_SORTED_UNNORMALIZED___CHANNEL_CHUNK_DATA_AMPLITUDES()
{
///////////////////////////////////////////
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
=
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.OrderBy(PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL => PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL.CHANNEL_NUMBER)
.ThenBy(PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL => PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL.SAMPLE_COUNTER)
.ToList();
///////////////////////////////////////////
StringBuilder PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER______NON_NORMALIZED = new StringBuilder();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER______NON_NORMALIZED.Clear();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER______NON_NORMALIZED
.AppendLine("sorted_channel,sorted_sample_counter,unnormalized_amplitude,unnormalized_decibel");
double amplitude = 0;
foreach (PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL _samples_data in PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL)
{
amplitude = 0;
amplitude = _samples_data.AMPLITUDE_NORMALIZED * (double)(short.MaxValue);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER______NON_NORMALIZED
.AppendLine
(
_samples_data.CHANNEL_NUMBER
+ " , " +
_samples_data.SAMPLE_COUNTER
+ " , " +
amplitude
+ " , " +
20 * Math.Log10(amplitude)
);
}//foreach(PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL _samples_data in PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL)
System.IO.File.WriteAllText(saan_waves_filesnames + "_UNNORMALIZED_DATA_saan_writes.txt", PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER______NON_NORMALIZED.ToString());
}//async Task SAAN_REPORT_SORTED_UNNORMALIZED___CHANNEL_CHUNK_DATA_AMPLITUDES()
////// See the end of this message for details on invoking
////// just -in-time(JIT) debugging instead of this dialog box.
////// * *************Exception Text * *************
////// System.AggregateException: One or more errors occurred. --->System.NullReferenceException: Object reference not set to an instance of an object.
////// at System.Text.StringBuilder.Append(String value)
////// at System.Text.StringBuilder.AppendLine(String value)
////// at SAANAUDS.Wave.WaveFileReader.< SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES > d__12.MoveNext() in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 286
////// -- - End of stack trace from previous location where exception was thrown-- -
////// at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
////// at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
////// at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
////// at SAANAUDS.Wave.WaveFileReader.<< Dispose > b__19_0 > d.MoveNext()
////// -- - End of inner exception stack trace-- -
////// at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
////// at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
////// at System.Threading.Tasks.Task.Wait()
////// at SAANAUDS.Wave.WaveFileReader.Dispose(Boolean disposing) in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 677
////// at System.IO.Stream.Close()
////// at SAANAUDS.Wave.PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS.ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER(String inputFilePath___for_wav_files) in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 1249
////// at ExcelFormulaParser_GT_PARSERSample.SampleForm.button_GTWAVS_OPEN_WAV_FILES_Click(Object sender, EventArgs e) in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SampleForm.cs:line 52473
////// at System.Windows.Forms.Control.OnClick(EventArgs e)
////// at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
////// at System.Windows.Forms.Control.WmMouseUp(Message & m, MouseButtons button, Int32 clicks)
////// at System.Windows.Forms.Control.WndProc(Message & m)
////// at System.Windows.Forms.ButtonBase.WndProc(Message & m)
////// at System.Windows.Forms.Button.WndProc(Message & m)
////// at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
////// ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
//////at System.Text.StringBuilder.Append(String value)
////// at System.Text.StringBuilder.AppendLine(String value)
////// at SAANAUDS.Wave.WaveFileReader.< SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES > d__12.MoveNext() in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 286
////// -- - End of stack trace from previous location where exception was thrown-- -
////// at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
////// at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
////// at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
////// at SAANAUDS.Wave.WaveFileReader.<< Dispose > b__19_0 > d.MoveNext() < ---
/// <summary>Supports opening a WAV file</summary>
/// <remarks>The WAV file format is a real mess, but we will only
/// support the basic WAV file format which actually covers the vast
/// majority of WAV files out there. For more WAV file format information
/// visit www.wotsit.org. If you have a WAV file that can't be read by
/// this class, email it to the SAANAUDS project and we will probably
/// fix this reader to support it
/// </remarks>
public WaveFileReader(String waveFile) :
this(File.OpenRead(waveFile))
{
saan_waves_filesnames = waveFile;
int ___found_header_size = WaveFileWriter.CalculateHEADERS_SIZE___SAAN(waveFile);
long ___found_data_chunk_size = WaveFileWriter.CalculateDataChunkSize___SAAN(waveFile);
System.Windows.Forms.MessageBox.Show(" int ___found_header_size = WaveFileWriter.CalculateHEADERS_SIZE___SAAN(waveFile) ___found_header_size = " + ___found_header_size);
System.Windows.Forms.MessageBox.Show(" long ___found_data_chunk_size= WaveFileWriter.CalculateDataChunkSize___SAAN(waveFile) ___found_data_chunk_size = " + ___found_data_chunk_size);
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
= new List<PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL>();
PUBLIC_LIST_OF_PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
.Clear();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER = new StringBuilder();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.Clear();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("reading from filenames= " + waveFile);
ownInput = true;
}
/// <summary>
/// Creates a Wave File Reader based on an input stream
/// </summary>
/// <param name="inputStream">The input stream containing a WAV file including header</param>
public WaveFileReader(Stream inputStream)
{
if(saan_waves_filesnames.TrimEnd().TrimStart().Trim().Length==0)
{
saan_waves_filesnames
= ExcelFormulaParser_GT_PARSERSample.Program.public_static_string_GT_folder
+ "_wav_files_log_" + System.DateTime.Now.ToString("ddmmyyyyhhmmss")+".txt";
}// if(saan_waves_filesnames.TrimEnd().TrimStart().Trim().Length==0)
SAAN_Wav_Streams = inputStream;
//////int ___found_header_size = WaveFileWriter.CalculateHEADERS_SIZE___SAAN(saan_waves_filesnames);
//////long ___found_data_chunk_size= WaveFileWriter.CalculateDataChunkSize___SAAN(saan_waves_filesnames);
//////System.Windows.Forms.MessageBox.Show(" int ___found_header_size = WaveFileWriter.CalculateHEADERS_SIZE___SAAN(saan_waves_filesnames) ___found_header_size = " + ___found_header_size);
//////System.Windows.Forms.MessageBox.Show(" long ___found_data_chunk_size= WaveFileWriter.CalculateDataChunkSize___SAAN(saan_waves_filesnames) ___found_data_chunk_size = " + ___found_data_chunk_size);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER = new StringBuilder();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.Clear();
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("reading from streams(long Length size)= " + inputStream.Length);
this.waveStream = inputStream;
var chunkReader = new WaveFileChunkReader();
try
{
chunkReader.ReadWaveHeader(inputStream);
this.waveFormat = chunkReader.WaveFormat;
this.dataPosition = chunkReader.DataChunkPosition;
this.dataChunkLength = chunkReader.DataChunkLength;
this.chunks = chunkReader.RiffChunks;
}
catch (Exception _excp_toreadchunks)
{
System.Windows.Forms.MessageBox.Show("_excp_toreadchunks chunkReader.ReadWaveHeader(inputStream);" + _excp_toreadchunks.Message + " " + _excp_toreadchunks.StackTrace.ToString());
}//catch(Exception _excp_toreadchunks)
//////this.SAAN_FINDS_WAV_HEADER_SIZE = (int)(this.dataPosition - this.dataChunkLength);
this.SAAN_FINDS_WAV_HEADER_SIZE = Math.Max((int)(this.dataPosition),0);// - this.dataChunkLength);
////// // Calculate the header size
////// int headerSize = (int)(waveReader.Position - waveReader.Length);
////// return Math.Max(headerSize, 0); // Ensure the header size is non-negative
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("chunkReader.ReadWaveHeader(inputStream) chunkReader.WaveFormat= " + this.WaveFormat.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("long chunkReader.DataChunkPosition= " + this.dataPosition);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("long chunkReader.DataChunkLength= " + this.dataChunkLength);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("list chunkReader.RiffChunks Count= " + this.chunks.Count);
double _temp_chunk_counter = 0;
foreach(RiffChunk _saan_riff_chunk in this.chunks)
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine
(
"RiffChunk counter = "+ _temp_chunk_counter
+ " Identifier= " + _saan_riff_chunk.Identifier
+ " IdentifierAsString= " + _saan_riff_chunk.IdentifierAsString
+ " Length= " + _saan_riff_chunk.Length
+ " StreamPosition=" + _saan_riff_chunk.StreamPosition
+ " report= " + _saan_riff_chunk.ToString()
);
///saan is adding this still the data dumps are not found
GetChunkData(_saan_riff_chunk);
_temp_chunk_counter++;
}//foreach(RiffChunk _saan_riff_chunk in this.chunks)
Position = 0;
}//public WaveFileReader(Stream inputStream)
/// <summary>
/// Gets a list of the additional chunks found in this file
/// </summary>
public List<RiffChunk> ExtraChunks
{
get
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("ExtraChunks chunks.Count= " + chunks.Count);
return chunks;
}
}
/// <summary>
/// Gets the data for the specified chunk
/// </summary>
public byte[] GetChunkData(RiffChunk chunk)
{
long oldPosition = waveStream.Position;
waveStream.Position = chunk.StreamPosition;
byte[] data = new byte[chunk.Length];
waveStream.Read(data, 0, data.Length);
waveStream.Position = oldPosition;
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("oldPosition= " + oldPosition + " Position= " + Position);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("RiffChunk chunk data = "+ chunk.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("RiffChunk chunk long Position = " + chunk.StreamPosition);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("RiffChunk chunk int Length = " + chunk.Length);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("RiffChunk chunk int Identifier = " + chunk.Identifier);
return data;
}
/// <summary>
/// Cleans up the resources associated with this WaveFileReader
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
// Release managed resources.
if (waveStream != null)
{
// only dispose our source if we created it
if (ownInput)
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("disposing this.dataChunkLength= " + this.dataChunkLength);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("disposing this.SAAN_FINDS_WAV_HEADER_SIZE= " + this.SAAN_FINDS_WAV_HEADER_SIZE);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("disposing this.Position= " + this.Position);
try
{
/// await SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES(saan_waves_filesnames, SAAN_FINDS_WAV_HEADER_SIZE, this.waveFormat.SampleRate, this.waveFormat.Channels, this.waveFormat.BitsPerSample);
Task.Run(async () => await SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES(saan_waves_filesnames, SAAN_FINDS_WAV_HEADER_SIZE, this.waveFormat.SampleRate, this.waveFormat.Channels, this.waveFormat.BitsPerSample)).Wait();
Task.Run(async () => await SAAN_REPORT_SORTED_UNNORMALIZED___CHANNEL_CHUNK_DATA_AMPLITUDES()).Wait();
/////////////////////////////////////////////////////////////////////////////////////////////////////
/// PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("");
System.IO.File.WriteAllText(saan_waves_filesnames + "_saan_writes.txt",PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.ToString());
}
catch (Exception _excp_large_files_can_have_issues)
{
System.Windows.Forms.MessageBox.Show("_excp_large_files_can_have_issues " + _excp_large_files_can_have_issues.Message + "\r\n"+ _excp_large_files_can_have_issues.StackTrace.ToString());
}//catch(Exception _excp_large_files_can_have_issues)
//////////////////////////////////////////////////////////////////////////////////
waveStream.Close();
}
waveStream = null;
System.Windows.Forms.MessageBox.Show("The Tasks writing completes inside the SAANAUDS.Wave. public class WaveFileReader : WaveStream");
}
}
else
{
System.Diagnostics.Debug.Assert(false, "WaveFileReader was not disposed");
}
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose(disposing);
}
/// <summary>
/// <see cref="WaveStream.WaveFormat"/>
/// </summary>
public override WaveFormat WaveFormat
{
get
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat Encoding= " + waveFormat.Encoding.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int SampleRate= " + waveFormat.SampleRate.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int ExtraSize= " + waveFormat.ExtraSize.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int AverageBytesPerSecond= " + waveFormat.AverageBytesPerSecond.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int BitsPerSample= " + waveFormat.BitsPerSample.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int BlockAlign= " + waveFormat.BlockAlign.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int BitsPerSample= " + waveFormat.BitsPerSample.ToString());
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int Channels= " + waveFormat.Channels.ToString());
////// // Calculate the header size
////// int headerSize = (int)(waveReader.Position - waveReader.Length);
////// return Math.Max(headerSize, 0); // Ensure the header size is non-negative
//stack overflow PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat int SampleCount= " + this.SampleCount.ToString());
///this line was not there
///saan adds this
//kkk
///////////////////////////////////////////////////////////////////// this line was not there //////////
///////////////////////////////////////////////////////////////////// this line was not there //////////
///////////////////////////////////////////////////////////////////// this line was not there //////////
float[] ___temp_saan_floats_array = ReadNextSampleFrame();
///////////////////////////////////////////////////////////////////// this line was not there //////////
///////////////////////////////////////////////////////////////////// this line was not there //////////
///////////////////////////////////////////////////////////////////// this line was not there //////////
return waveFormat;
}
}
/// <summary>
/// This is the length of audio data contained in this WAV file, in bytes
/// (i.e. the byte length of the data chunk, not the length of the WAV file itself)
/// <see cref="WaveStream.WaveFormat"/>
/// </summary>
public override long Length
{
get
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat long dataChunkLength= " + dataChunkLength);
return dataChunkLength;
}
}
/// <summary>
/// Number of Samples (if possible to calculate)
/// This currently does not take into account number of channels, so
/// divide again by number of channels if you want the number of
/// audio 'frames'
/// </summary>
public long SampleCount
{
get
{
if (waveFormat.Encoding == WaveFormatEncoding.Pcm ||
waveFormat.Encoding == WaveFormatEncoding.Extensible ||
waveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveFormat long SampleeCount=dataChunkLength / BlockAlign = " + (dataChunkLength / BlockAlign));
return dataChunkLength / BlockAlign;
}
// n.b. if there is a fact chunk, you can use that to get the number of samples
throw new InvalidOperationException("Sample count is calculated only for the standard encodings");
}
}
/// <summary>
/// Position in the WAV data chunk.
/// <see cref="Stream.Position"/>
/// </summary>
public override long Position
{
get
{
try
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveStream.Position - dataPosition = " + waveStream.Position + " - " + dataPosition + " = " + (waveStream.Position - dataPosition));
}
catch(Exception _excp)
{
}//catch(Exception _excp)
/// this try catch is important to save the playback to avoid errors
return waveStream.Position - dataPosition;
}
set
{
lock (lockObject)
{
value = Math.Min(value, Length);
// make sure we don't get out of sync
value -= (value % waveFormat.BlockAlign);
waveStream.Position = value + dataPosition;
}
}
}
/// <summary>
/// Reads bytes from the Wave File
/// <see cref="Stream.Read"/>
/// </summary>
///
/// ///in c sharp byte is 8 bit
/// ///in c sharp byte is 8 bit
/// /// ///in c sharp byte is 8 bit
/// /// ///in c sharp short is 16 bit
/// /// ///in c sharp int is 32 bit
/// /// ///in c sharp long is 64 bit
/// /// ///in c sharp float is 32 bit
/// /// ///in c sharp double is 64 bit
/// /// ///in c sharp decimal is 128 bit
/// /// ///in c sharp char is 16 bit
/// /// ///in c sharp bool is 8 bit
///
public override int Read(byte[] array, int offset, int count)
{
if (count % waveFormat.BlockAlign != 0)
{
throw new ArgumentException(String.Format("Must read complete blocks: requested {0}, block align is {1}",count,this.WaveFormat.BlockAlign));
}
lock (lockObject)
{
// sometimes there is more junk at the end of the file past the data chunk
if (Position + count > dataChunkLength)
{
try
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("sometimes there is more junk at the end of the file past the data chunk size of junk = " + (int)(dataChunkLength - Position));
}
catch (Exception _excp)
{
}//catch(Exception _excp)
/// this try catch is important to save the playback to avoid errors
///
count = (int) (dataChunkLength - Position);
}
int ___tempData = 0;
___tempData = waveStream.Read(array, offset, count);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("waveStream.Read(array, offset, count) = ___tempData= " + ___tempData);
return ___tempData;// waveStream.Read(array, offset, count);
}
}
/// <summary>
/// Attempts to read the next sample or group of samples as floating point normalised into the range -1.0f to 1.0f
/// </summary>
/// <returns>An array of samples, 1 for mono, 2 for stereo etc. Null indicates end of file reached
/// </returns>
public float[] ReadNextSampleFrame()
{
switch (waveFormat.Encoding)
{
case WaveFormatEncoding.Pcm:
case WaveFormatEncoding.IeeeFloat:
case WaveFormatEncoding.Extensible: // n.b. not necessarily PCM, should probably write more code to handle this case
break;
default:
throw new InvalidOperationException("Only 16, 24 or 32 bit PCM or IEEE float audio data supported");
}// switch (waveFormat.Encoding)
var sampleFrame = new float[waveFormat.Channels];
int bytesToRead = waveFormat.Channels*(waveFormat.BitsPerSample/8);
byte[] raw = new byte[bytesToRead];
int bytesRead = Read(raw, 0, bytesToRead);
if (bytesRead == 0) return null; // end of file
if (bytesRead < bytesToRead)
{ throw new InvalidDataException("Unexpected end of file"); }
int offset = 0;
for (int channel = 0; channel < waveFormat.Channels; channel++)
{
if (waveFormat.BitsPerSample == 16)
{
sampleFrame[channel] = BitConverter.ToInt16(raw, offset)/32768f;
offset += 2;
try
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("channel = " + channel + " 16 Bit Sample Offset 2 float_data = " + sampleFrame[channel]);
}
catch (Exception _excp)
{
}//catch(Exception _excp)
/// this try catch is important to save the playback to avoid errors
}
else if (waveFormat.BitsPerSample == 24)
{
sampleFrame[channel] = (((sbyte)raw[offset + 2] << 16) | (raw[offset + 1] << 8) | raw[offset]) / 8388608f;
offset += 3;
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("channel = " + channel + " 24 Bit Sample Offset 3 float_data = " + sampleFrame[channel]);
}
else if (waveFormat.BitsPerSample == 32 && waveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
{
sampleFrame[channel] = BitConverter.ToSingle(raw, offset);
offset += 4;
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("channel = " + channel + " 32 Bit Sample Offset 4 IEEE_float_data = " + sampleFrame[channel]);
}
else if (waveFormat.BitsPerSample == 32)
{
sampleFrame[channel] = BitConverter.ToInt32(raw, offset) / (Int32.MaxValue + 1f);
offset += 4;
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("channel = " + channel + " 32 Bit Sample Offset 4 float_data = " + sampleFrame[channel]);
}
else
{
throw new InvalidOperationException("Unsupported bit depth");
}
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("\r\nnow to log float data for channels sampleFrame= " + sampleFrame.Length + "\r\n");
////////////////////// saan adds this for sampleFrames channelwise data ///////////////
for (int ___datacounter=0;___datacounter< sampleFrame.Length;___datacounter++)
{
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.AppendLine("channel = " + channel);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.Append(" " + ___datacounter);
PUBLIC_SAAN_STRINGBUILDER_FOR_WAV_FILES_READER.Append(" " + sampleFrame[___datacounter] + "\r\n");
}//for(int ___datacounter=0;___datacounter< sampleFrame.Length;___datacounter++)
}//for (int channel = 0; channel < waveFormat.Channels; channel++)
return sampleFrame;
}
/// <summary>
/// Attempts to read a sample into a float. n.b. only applicable for uncompressed formats
/// Will normalise the value read into the range -1.0f to 1.0f if it comes from a PCM encoding
/// </summary>
/// <returns>False if the end of the WAV data chunk was reached</returns>
[Obsolete("Use ReadNextSampleFrame instead (this version does not support stereo properly)")]
public bool TryReadFloat(out float sampleValue)
{
var sf = ReadNextSampleFrame();
sampleValue = sf != null ? sf[0] : 0;
return sf != null;
}
}// public class WaveFileReader : WaveStream
public class PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
{
public int CHANNEL_NUMBER = 0;
public double SAMPLE_COUNTER = 0;
public double AMPLITUDE_NORMALIZED = 0;
public double DECIBEL = 0;
/// ///in c sharp byte is 8 bit
/// ///in c sharp byte is 8 bit
/// /// ///in c sharp byte is 8 bit
/// /// ///in c sharp short is 16 bit
/// /// ///in c sharp int is 32 bit
/// /// ///in c sharp long is 64 bit
/// /// ///in c sharp float is 32 bit
/// /// ///in c sharp double is 64 bit
/// /// ///in c sharp decimal is 128 bit
/// /// ///in c sharp char is 16 bit
/// /// ///in c sharp bool is 8 bit
///
public PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL()
{
this.CHANNEL_NUMBER = 0;
this.SAMPLE_COUNTER = 0;
this.AMPLITUDE_NORMALIZED = 0;
this.DECIBEL = 0;
}//public PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL()
}// public class PUBLIC_CLASS_SAAN_CHANNEL_SAMPLECOUNT_NORMALIZED_AMPLITUDE_DECIBEL
public static class PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS
{
public static int PUBLIC_STATIC_INT_FILE_COUNTER = 0;
public static string PUBLIC_STATIC_STRING_CURRENT_FILES_NAME = "";
public static double PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;
public static double PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y = 0;
//////public static void ExtractAndWriteChannelAmplitudes___SAAN_STYLES_SEPERATE_FILES_FOR_CHANNELS(string input_wav_FilePath)
//////{
////// using (WaveFileReader waveReader = new WaveFileReader(input_wav_FilePath))
////// {
////// int channels = waveReader.WaveFormat.Channels;
////// int sampleRate = waveReader.WaveFormat.SampleRate;
////// for (int channel = 0; channel < channels; channel++)
////// {
////// // Create a separate text file for each channel
////// string outputFilePath = $"{Path.GetFileNameWithoutExtension(input_wav_FilePath)}_channel{channel + 1}.txt";
////// using (StreamWriter writer = new StreamWriter(outputFilePath))
////// {
////// // Write the heading to the file
////// writer.WriteLine("Amplitudes");
////// // Read and write amplitude values for the current channel
////// float[] buffer = new float[waveReader.WaveFormat.BlockAlign / 2]; // Assuming 16-bit samples
////// while (waveReader.Read(buffer, 0, buffer.Length) > 0)
////// {
////// for (int i = 0; i < buffer.Length; i++)
////// {
////// // Write amplitude value to the text file
////// writer.WriteLine(buffer[i]);
////// }//for (int i = 0; i < buffer.Length; i++)
////// }//while (waveReader.Read(buffer, 0, buffer.Length) > 0)
////// }//using (StreamWriter writer = new StreamWriter(outputFilePath))
////// Console.WriteLine($"Channel {channel + 1} amplitudes written to: {outputFilePath}");
////// }// for (int channel = 0; channel < channels; channel++)
////// }//using (WaveFileReader waveReader = new WaveFileReader(inputFilePath))
//////}// public static void ExtractAndWriteChannelAmplitudes___SAAN_STYLES_SEPERATE_FILES_FOR_CHANNELS(string input_wav_FilePath)
//calling convention PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS.ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER
public static void ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER(string inputFilePath___for_wav_files)
{
////// See the end of this message for details on invoking
////// just -in-time(JIT) debugging instead of this dialog box.
////// * *************Exception Text * *************
////// System.AggregateException: One or more errors occurred. --->System.NullReferenceException: Object reference not set to an instance of an object.
////// at System.Text.StringBuilder.Append(String value)
////// at System.Text.StringBuilder.AppendLine(String value)
////// at SAANAUDS.Wave.WaveFileReader.< SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES > d__12.MoveNext() in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 286
////// -- - End of stack trace from previous location where exception was thrown-- -
////// at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
////// at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
////// at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
////// at SAANAUDS.Wave.WaveFileReader.<< Dispose > b__19_0 > d.MoveNext()
////// -- - End of inner exception stack trace-- -
////// at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
////// at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
////// at System.Threading.Tasks.Task.Wait()
////// at SAANAUDS.Wave.WaveFileReader.Dispose(Boolean disposing) in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 677
////// at System.IO.Stream.Close()
////// at SAANAUDS.Wave.PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS.ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER(String inputFilePath___for_wav_files) in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 1249
////// at ExcelFormulaParser_GT_PARSERSample.SampleForm.button_GTWAVS_OPEN_WAV_FILES_Click(Object sender, EventArgs e) in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SampleForm.cs:line 52473
////// at System.Windows.Forms.Control.OnClick(EventArgs e)
////// at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
////// at System.Windows.Forms.Control.WmMouseUp(Message & m, MouseButtons button, Int32 clicks)
////// at System.Windows.Forms.Control.WndProc(Message & m)
////// at System.Windows.Forms.ButtonBase.WndProc(Message & m)
////// at System.Windows.Forms.Button.WndProc(Message & m)
////// at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
////// ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
//////at System.Text.StringBuilder.Append(String value)
////// at System.Text.StringBuilder.AppendLine(String value)
////// at SAANAUDS.Wave.WaveFileReader.< SAAN_REPORT_CHANNEL_CHUNK_DATA_AMPLITUDES > d__12.MoveNext() in F:\sanjoy_workouts\C_SHARPS_DEVELOPMENT_SOL\excelformulaparser\DOING_GT06012020plus\DSMSETS_ANI_DNGIFGTTODOINOFFICE\ExcelFormulaParserSample\SAANAUDS\SAANSAUDSAPI_Wave_WaveStreams_WaveFileReader.CS:line 286
////// -- - End of stack trace from previous location where exception was thrown-- -
////// at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
////// at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
////// at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
////// at SAANAUDS.Wave.WaveFileReader.<< Dispose > b__19_0 > d.MoveNext() < ---
using (WaveFileReader waveReader = new WaveFileReader(inputFilePath___for_wav_files))
{
int channels = waveReader.WaveFormat.Channels;
int sampleRate = waveReader.WaveFormat.SampleRate;
for (int channel = 0; channel < channels; channel++)
{
// Create a separate text file for each channel
string outputFilePath = $"{Path.GetFileNameWithoutExtension(inputFilePath___for_wav_files)}_channel{channel + 1}.txt";
using (StreamWriter writer = new StreamWriter(outputFilePath))
{
try
{
// Write the heading to the file
writer.WriteLine("Amplitudes");
// Read and write amplitude values for the current channel
byte[] buffer = new byte[waveReader.WaveFormat.BlockAlign]; // BlockAlign represents the size of one sample for all channels
int bytesRead;
while ((bytesRead = waveReader.Read(buffer, 0, buffer.Length)) > 0)
{
for (int i = 0; i < bytesRead / 2; i += channels) // Assuming 16-bit samples
{
try
{
short sampleValue = BitConverter.ToInt16(buffer, i);
float amplitude = sampleValue / (float)short.MaxValue;
// Write amplitude value to the text file
/// writer.WriteLine(amplitude.ToString("G27"));
writer.WriteLine(Math.Round((double)amplitude,3)); //.ToString("G27")
}
catch (Exception ___excp_to_dumpData___for_loop)
{
// writer.WriteLine("0.0003001");
writer.Close();
}//catch (Exception ___excp_to_dumpData___for_loop)
}//for (int i = 0; i < bytesRead / 2; i += channels) // Assuming 16-bit samples
}// while ((bytesRead = waveReader.Read(buffer, 0, buffer.Length)) > 0)
}
catch (Exception ___excp_to_dumpData)
{
}//catch(Exception ___excp_to_dumpData)
writer.Close();
}//using (StreamWriter writer = new StreamWriter(outputFilePath))
// Console.WriteLine($"Channel {channel + 1} amplitudes written to: {outputFilePath}");
}// for (int channel = 0; channel < channels; channel++)
}//using (StreamWriter writer = new StreamWriter(outputFilePath))
}//public static void ExtractAndWriteChannelAmplitudes______SAAN_STYLE_CHANNELS_AMPLITUDES_DUMPER(string inputFilePath___for_wav_files)
public static void ProcessAllWavFiles___FOR_SOUNDS_BANK_DATA_DUMPING(string directoryPath,ref System.Windows.Forms.ProgressBar ___report_progressBar)
{
string[] wavFiles = Directory.GetFiles(directoryPath, "*.wav");
StringBuilder finalOutput_STRINGSBUILDER = new StringBuilder();
int ___numbers_of_wav_files_processed = 0;
___report_progressBar.Maximum = wavFiles.Length + 3;
___report_progressBar.Value = ___numbers_of_wav_files_processed;
___report_progressBar.Invalidate();
___report_progressBar.Refresh();
foreach (string wavFile in wavFiles)
{
___report_progressBar.Value = ___numbers_of_wav_files_processed;
___report_progressBar.Invalidate();
___report_progressBar.Refresh();
ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(wavFile, ref finalOutput_STRINGSBUILDER, directoryPath);
___numbers_of_wav_files_processed++;
}// foreach (string wavFile in wavFiles)
// ___report_progressBar.Maximum = wavFiles.Length + 3;
___report_progressBar.Value = ___report_progressBar.Maximum;//
// Write the collected information to a single text file
File.WriteAllText(Path.Combine(directoryPath, "SAAN_SOUNDS_BANKS_COMPILED_output.txt"), finalOutput_STRINGSBUILDER.ToString());
}//public static void ProcessAllWavFiles___FOR_SOUNDS_BANK_DATA_DUMPING(string directoryPath)
//////public static void ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(string inputFilePath, StringBuilder finalOutput_STRINGSBUILDER)
//////{
////// // Existing code for extracting channel amplitudes
////// // ...
////// int channels = 0;
////// int sampleRate = 0;
////// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
////// {
////// using (BinaryReader binaryReader = new BinaryReader(fileStream))
////// {
////// INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
////// for (int channel = 0; channel < channels; channel++)
////// {
////// // Existing code for processing amplitudes
////// // ...
////// // Append information to the finalOutput StringBuilder
////// finalOutput_STRINGSBUILDER.AppendLine($"{Path.GetFileName(inputFilePath)},{___temp_samples_count_for_this_channel},{sampleRate},{amplitude.ToString("F6")}");
////// }// for (int channel = 0; channel < channels; channel++)
////// }//using (BinaryReader binaryReader = new BinaryReader(fileStream))
////// }//using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
//////}//public static void ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(string inputFilePath, StringBuilder finalOutput)
// Call the ProcessAllWavFiles method with the desired directory path
//CALLING CONVENTION SAANAUDS.Wave.PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS.READ_ALL_WAV_FILES_IN_SOUNDSBANK_FOLDER_TO_REPORT_SAMPLES_DATA___Main
public static void READ_ALL_WAV_FILES_IN_SOUNDSBANK_FOLDER_TO_REPORT_SAMPLES_DATA___Main(string directoryPath_FOR_SAMPLES_WAVE_BANK_WAVE_FILES, ref System.Windows.Forms.ProgressBar ___report_progressbar)
{
string directoryPath = directoryPath_FOR_SAMPLES_WAVE_BANK_WAVE_FILES;//"your_directory_path_here";
ProcessAllWavFiles___FOR_SOUNDS_BANK_DATA_DUMPING(directoryPath , ref ___report_progressbar);
}//public static void READ_ALL_WAV_FILES_IN_SOUNDSBANK_FOLDER_TO_REPORT_SAMPLES_DATA___Main(STRING directoryPath_FOR_SAMPLES_WAVE_BANK_WAVE_FILES)
public static void ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(string inputFilePath,ref StringBuilder finalOutput_STRINGSBUILDER,string folder_path)
{
int channels = 0;
int sampleRate = 0;
StringBuilder ___internal_stringbuilder_for_direct_files_appending = new StringBuilder();
___internal_stringbuilder_for_direct_files_appending.Clear();
___internal_stringbuilder_for_direct_files_appending
.AppendLine("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated ");
StringBuilder ___internal_stringbuilder_for_small_rows_appending = new StringBuilder();
___internal_stringbuilder_for_small_rows_appending.Clear();
//////////////////////////////////////////////////////////////////////////////////////////////////////////
___internal_stringbuilder_for_small_rows_appending
.AppendLine
(
inputFilePath+",,,,"
);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
///
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;/// RESETS THE X FOR NEW FILES
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y =
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+ 3000;/// INCREASES THE Y 3000 UPWARDS FOR NEW FILES READING STARTS
PUBLIC_STATIC_INT_FILE_COUNTER++;
PUBLIC_STATIC_STRING_CURRENT_FILES_NAME = inputFilePath;
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_ON_FRONT_VIEW_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
0
,
300
,
"FILESNAMES"
,
PUBLIC_STATIC_INT_FILE_COUNTER.ToString() + " " + PUBLIC_STATIC_STRING_CURRENT_FILES_NAME
,
"XDATA_CHECKING"
,
PUBLIC_STATIC_INT_FILE_COUNTER ^ 250
)
;
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
for (int channel = 0; channel < channels; channel++)
{
int bytesPerSample = 2; // Assuming 16-bit samples
//////if (ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS % 8 == 0)
//////{
////// bytesPerSample = ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8;
//////}
//////else
//////{
////// bytesPerSample = (int)(ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8);
//////}
/// FOR SOUNDS BANKS WE WILL NOT SAY THIS System.Windows.Forms.MessageBox.Show("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
double ___temp_samples_count_for_this_channel = 0;
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
//////finalOutput_STRINGSBUILDER.AppendLine("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
//////finalOutput_STRINGSBUILDER.AppendLine($"{Path.GetFileName(inputFilePath)},{___temp_samples_count_for_this_channel},{sampleRate},{amplitude.ToString("F6")}");
___internal_stringbuilder_for_direct_files_appending
.AppendLine($"{channel},{sampleRate}" +
$",{Path.GetFileName(inputFilePath)}" +
$",{___temp_samples_count_for_this_channel}" +
$",{sampleRate}" +
$",{amplitude.ToString("F6")}");
___internal_stringbuilder_for_small_rows_appending
.AppendLine
(
$"" +
$",{___temp_samples_count_for_this_channel}" +
$",{amplitude.ToString("F6")}"
);
/// FOR REFERENCES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;/// RESETS THE X FOR NEW FILES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y =
/// FOR REFERENCES ////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
/// FOR REFERENCES ////// + 3000;/// INCREASES THE Y 3000 UPWARDS FOR NEW FILES READING STARTS
/// FOR REFERENCES
///
//////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
////// =
////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X + 10;
/// FOR EACH SAMPLES IT INCREASES X TO 10 UNITS
/// WE WILL NOT CHANGE THIS PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_line_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
,
0
,
"layer_mods_250_amplitudes_" + (Math.Abs((double)amplitude) * 100000 % 250).ToString()
,
"xdata_checking"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
-
(___temp_samples_count_for_this_channel.ToString().Length) * 6
-30
,
0
,
90
,
6
,
"bottom_text"
,
___temp_samples_count_for_this_channel.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
+
300* (Math.Sign((double)amplitude))
,
0
,
90
,
6
,
"bottom_text"
, amplitude.ToString("F6")
.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
/////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
}// while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
////// WE CAN DO THE ANALYSIS ON THE ACCUMULATED DATA FOR THE CURRENT OBJECTS OF AMPLITUDES AND THE CONDITIONS OF THE SLOPE CHANGES LISTS
///THESE KIND OF ANALYSIS IS MORE DETAILED KIND OF DATA HANDLING AND ANALYSIS ON THE WAV FILES TO GET MORE INFORMATIONS FOR TOPOLOGY LEVEL UNDERSTANDINGS
///THESE WILL GIVE US THE POWER TO DO ABSTRACT CHANGES ON THE SEQUENCES OF THE OBJECTS AND THERE ARE OPPERTUNITIES TO CHANGE THE MOODS WITH SOME RANGES OF WITHIN RANGE CHANGES
System.IO.File.AppendAllText
(
folder_path + "\\within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"
,
"\r\n"+ ___internal_stringbuilder_for_direct_files_appending.ToString()
);
/////////////////////////////////////////////////////////////////////////////////////////////
System.IO.File.AppendAllText
(
folder_path + "\\simplest_csv_like_data.txt"
,
___internal_stringbuilder_for_small_rows_appending.ToString()
/// "\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
);
}// for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
}//public static void ProcessSingleWavFile___TO_DUMP_THE_SAMPLES_DATA_SOUNDS_BANKS(string inputFilePath, StringBuilder finalOutput_STRINGSBUILDER)
//calling convention PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS.INDEPENDENT_ExtractAndWriteChannelAmplitudes
public static void INDEPENDENT_ExtractAndWriteChannelAmplitudes(string inputFilePath)
{
StringBuilder ___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
= new StringBuilder();
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.Clear();
string string___do_you_need_detailed_report_log = "NO";
//////using Microsoft.VisualBasic;
//////string input = Interaction.InputBox("Prompt", "Title", "Default", -1, -1);
//what_to_search_text_substring = Microsoft.VisualBasic.VBCodeProvider.InputBox()
string___do_you_need_detailed_report_log = Microsoft.VisualBasic.Interaction.InputBox("DO YOU NEED DETAILED REPORT LOG (YES/NO)", "NO","NO");
string___do_you_need_detailed_report_log
= string___do_you_need_detailed_report_log.TrimEnd().TrimStart().Trim().ToUpper();
if( string___do_you_need_detailed_report_log.Contains("YES"))
{
System.Windows.Forms.MessageBox.Show("IT WILL TAKE LONG TIME AND WILL GENERATE HEAVY LOG FILE FOR DATA ANALYSIS ");
}//if( string___do_you_need_detailed_report_log.Contains("YES"))
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
"channel,sample_counter,found_in_wav_files___sampleRate___bit_depth_taken,found_the_millisecond,symmetry_of_amplitudes(-1 to +1) waves conventions"
);
double ___temp_max_milliseconds_from_every_channels = 0;
double ___temp_samples_count_for_this_channel = 0;
double ___temp_duration_found_for_this_channel = 0;
double ___temp_samples_count_found_till_now_in_current_channel = 0;
double ___temp_mins_fouund = 0;
double ___temp_secs_found = 0;
// (___temp_duration_found_for_this_channel / 60000) + "_mins" +
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
int channels = 0;
int sampleRate = 0;
// Read WAV header to get channels and sample rate
INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
for (int channel = 0; channel < channels; channel++)
{
___temp_samples_count_for_this_channel = 0;
___temp_duration_found_for_this_channel = 0;
___temp_mins_fouund = 0;
___temp_secs_found = 0;
// (___temp_duration_found_for_this_channel / 60000) + "_mins" +
// Create a separate text file for each channel
//////string outputFilePath = $"{Path.GetFileNameWithoutExtension(inputFilePath)}_channel{channel + 1}.txt";
///
string outputFilePath
=
//////System.IO.Directory.
//////Path.GetFileNameWithoutExtension(inputFilePath)
//////+"_channel_"+ (channel +1) +".txt";
inputFilePath + "_ch_" + (channel + 1) +"sps_"+ sampleRate + ".GTAMPS";// ".txt";
using (StreamWriter writer = new StreamWriter(outputFilePath))
{
// Write the heading to the file
writer.WriteLine("Amplitudes,default int bytesPerSample = 2; // Assuming 16-bit samples");
// Read and write amplitude values for the current channel
int bytesPerSample = 2; // Assuming 16-bit samples
if (
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
%8==0
)
{
bytesPerSample
=
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
/ 8; // two bytes is 8 bits
}
////// if (
////// ExcelFormulaParser_GT_PARSER
//////.SAANAUDS
//////.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
//////.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
//////% 8 == 0
//////)
else
{
bytesPerSample
=
(int)
(
ExcelFormulaParser_GT_PARSER
.SAANAUDS
.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
/ 8)
;
}// else of
////// if (
////// ExcelFormulaParser_GT_PARSER
//////.SAANAUDS
//////.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS
//////.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS
//////% 8 == 0
//////)
System.Windows.Forms.MessageBox.Show
("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
// Write amplitude value to the text file
// writer.WriteLine(amplitude);
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
/// writer.WriteLine(amplitude.ToString("F38"));
writer.WriteLine(amplitude.ToString("F8")); /// float type is 32 bit and it can support upto this
// writer.Write( ",");
// writer.Write( (Convert.ToDouble(amplitude) ) .ToString("G27"));
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
// Write amplitude value to the text file with 6 decimal places
// writer.WriteLine(amplitude.ToString("F6"));
// this writes bigger precissions
//////////////////////////////////////___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
//////////////////////////////////////.AppendLine
//////////////////////////////////////(
//////////////////////////////////////"channel,sample_counter,bit_depth_taken,found_the_millisecond,symmetry_of_amplitudes(-1 to +1) waves conventions"
//////////////////////////////////////);
///
//////for references ___temp_samples_count_for_this_channel = 0;
//////for references ___temp_duration_found_for_this_channel = 0;
___temp_max_milliseconds_from_every_channels
= Math.Max(___temp_max_milliseconds_from_every_channels, ___temp_duration_found_for_this_channel);
___temp_duration_found_for_this_channel
=
___temp_samples_count_for_this_channel / sampleRate;
___temp_mins_fouund =
(int)
( ___temp_duration_found_for_this_channel
/ 60000);
___temp_secs_found =
(int)(___temp_duration_found_for_this_channel / 1000)
-
(___temp_mins_fouund * 60);
if(string___do_you_need_detailed_report_log.Contains("YES"))
{
//inputFilePath + "_ch_" + (channel + 1) +"sps_"+ sampleRate + ".GTAMPS";// ".txt";
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
// (channel + 1) +","+ ___temp_samples_count_for_this_channel + ",read_sps(*8)= "+ ( bytesPerSample * 8 )+"," + ___temp_mins_fouund + "_mins and " + ___temp_secs_found + " real ms= " + ___temp_duration_found_for_this_channel.ToString("F6") + "," + amplitude.ToString("F6")
(channel + 1) + "," + ___temp_samples_count_for_this_channel + ",read_sps(*8)= " + (bytesPerSample * 8) + "," + ((___temp_duration_found_for_this_channel * 1000).ToString("F6")) + "," + amplitude.ToString("F6")
);
}
else
{
}// if(string___do_you_need_detailed_report_log.Contains("YES"))
}//while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
}//using (StreamWriter writer = new StreamWriter(outputFilePath))
/// no need for this Console.WriteLine($"Channel {channel + 1} amplitudes written to: {outputFilePath}");
///
___temp_duration_found_for_this_channel
=
___temp_samples_count_for_this_channel / sampleRate;
System.Windows.Forms.MessageBox.Show(" for channel = " + channel + " samples= " + ___temp_samples_count_for_this_channel + " durations= " + ___temp_mins_fouund + "_mins and " + ___temp_secs_found + " real_ms= " + ___temp_duration_found_for_this_channel);
}//for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
/////////////////////////////////////////////////////////////// wav files handles with milliseconds instead of micro seconds //////
ExcelFormulaParser_GT_PARSER
.GT_PARSERS
.public_static_class_simulations_CONTROLLER_for_gt_Class
.PUBLIC_STATIC_DOUBLE___WAV_FILES_AMPLITUDE_GENERATOR_DURATIONS_MILLISECONDS_FOUND
=
___temp_max_milliseconds_from_every_channels * 1000;
/////////////////////////////////////////////////////////////// wav files handles with milliseconds instead of micro seconds //////
if (string___do_you_need_detailed_report_log.Contains("YES"))
{
System.IO.File.WriteAllText
(
inputFilePath + "_det_report_not_import_this_is_csv_likes.log"
,
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.ToString()
);
}
else
{
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.AppendLine
(
"no data accumulated you asked for NO"
);
System.IO.File.WriteAllText
(
inputFilePath + "_det_report_not_import_this_is_csv_likes.log"
,
___saan_stringbuilder_to_report_details_with_sample_counts_with_milliseconds
.ToString()
);
}// else case of if (string___do_you_need_detailed_report_log.Contains("YES"))
}//public static void INDEPENDENT_ExtractAndWriteChannelAmplitudes(string inputFilePath)
public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
{
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
sampleRate = binaryReader.ReadInt32();
}// public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static void PUBLIC_STATIC_VOID_INDEPENDENT_READ_SINGLE_WAV_FILE_TO_CONVERT_ITS_REPORT_TO_DXF(string inputFilePath, ref ProgressBar progressbar)
{
StringBuilder ___internal_stringbuilder_for_direct_files_appending = new StringBuilder();
___internal_stringbuilder_for_direct_files_appending.Clear();
StringBuilder ___internal_stringbuilder_for_small_rows_appending = new StringBuilder();
___internal_stringbuilder_for_small_rows_appending.Clear();
string folder_path= Path.GetDirectoryName(inputFilePath);
int sampleRate = 44100;
/// int[] channels = { };
// short[] channels = { };
int channels = 0;
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
/// INDEPENDENT___ReadWaveHeader(binaryReader, out channels, out sampleRate);
// // // public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
// // // {
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
sampleRate = binaryReader.ReadInt32();
////////////// }// public static void INDEPENDENT___ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
for (int channel = 0; channel < channels; channel++)
{
int bytesPerSample = 2; // Assuming 16-bit samples
//////if (ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS % 8 == 0)
//////{
////// bytesPerSample = ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8;
//////}
//////else
//////{
////// bytesPerSample = (int)(ExcelFormulaParser_GT_PARSER.SAANAUDS.PUBLIC_STATIC_SAAN_LOGGER_VARIABLES_FOR_TRANSIENT_DATA_FOR_MIDI_EVENTS.PUBLIC_STATIC_INT_BIT_DEPTH_FOR_WAV_FILES_EXPORT___TAKEN_FROM_WAV_TAB_FOR_FORMS / 8);
//////}
/// FOR SOUNDS BANKS WE WILL NOT SAY THIS System.Windows.Forms.MessageBox.Show("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
byte[] buffer = new byte[channels * bytesPerSample];
double ___temp_samples_count_for_this_channel = 0;
while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
{
float amplitude = BitConverter.ToInt16(buffer, channel * bytesPerSample) / (float)short.MaxValue;
___temp_samples_count_for_this_channel++;
//////finalOutput_STRINGSBUILDER.AppendLine("CAUTION\r\nCAUTION\r\nCAUTION \r\n wav files handles milliseconds not microseconds like midi in PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILE_READER \r\n the wav files tab has bit depth to bytes per sample calculated = bytesPerSample = " + bytesPerSample);
//////finalOutput_STRINGSBUILDER.AppendLine($"{Path.GetFileName(inputFilePath)},{___temp_samples_count_for_this_channel},{sampleRate},{amplitude.ToString("F6")}");
___internal_stringbuilder_for_direct_files_appending
.AppendLine($"{channel},{sampleRate}" +
$",{Path.GetFileName(inputFilePath)}" +
$",{___temp_samples_count_for_this_channel}" +
$",{sampleRate}" +
$",{amplitude.ToString("F6")}");
___internal_stringbuilder_for_small_rows_appending
.AppendLine
(
$"" +
$",{___temp_samples_count_for_this_channel}" +
$",{amplitude.ToString("F6")}"
);
/// FOR REFERENCES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X = 0;/// RESETS THE X FOR NEW FILES
/// FOR REFERENCES //////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y =
/// FOR REFERENCES ////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
/// FOR REFERENCES ////// + 3000;/// INCREASES THE Y 3000 UPWARDS FOR NEW FILES READING STARTS
/// FOR REFERENCES
///
//////PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
////// =
////// PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X + 10;
/// FOR EACH SAMPLES IT INCREASES X TO 10 UNITS
/// WE WILL NOT CHANGE THIS PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_line_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
,
0
,
"layer_mods_250_amplitudes_" + (Math.Abs((double)amplitude) * 100000 % 250).ToString()
,
"xdata_checking"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
-
(___temp_samples_count_for_this_channel.ToString().Length) * 6
- 30
,
0
,
90
,
6
,
"bottom_text"
,
___temp_samples_count_for_this_channel.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(___temp_samples_count_for_this_channel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
+
300 * (Math.Sign((double)amplitude))
,
0
,
90
,
6
,
"bottom_text"
, amplitude.ToString("F6")
.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
/////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
/// /////////////////////////////////////////////////////////////////////////////// DO DATA POPULATIONS AND FOR THE ANALYSIS LISTS //////
}// while (binaryReader.Read(buffer, 0, buffer.Length) > 0)
////// WE CAN DO THE ANALYSIS ON THE ACCUMULATED DATA FOR THE CURRENT OBJECTS OF AMPLITUDES AND THE CONDITIONS OF THE SLOPE CHANGES LISTS
///THESE KIND OF ANALYSIS IS MORE DETAILED KIND OF DATA HANDLING AND ANALYSIS ON THE WAV FILES TO GET MORE INFORMATIONS FOR TOPOLOGY LEVEL UNDERSTANDINGS
///THESE WILL GIVE US THE POWER TO DO ABSTRACT CHANGES ON THE SEQUENCES OF THE OBJECTS AND THERE ARE OPPERTUNITIES TO CHANGE THE MOODS WITH SOME RANGES OF WITHIN RANGE CHANGES
System.IO.File.AppendAllText
(
folder_path + "\\within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"
,
"\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
);
/////////////////////////////////////////////////////////////////////////////////////////////
System.IO.File.AppendAllText
(
folder_path + "\\simplest_csv_like_data.txt"
,
___internal_stringbuilder_for_small_rows_appending.ToString()
/// "\r\n" + ___internal_stringbuilder_for_direct_files_appending.ToString()
);
}// for (int channel = 0; channel < channels; channel++)
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read))
}//public static void PUBLIC_STATIC_VOID_INDEPENDENT_READ_SINGLE_WAV_FILE_TO_CONVERT_ITS_REPORT_TO_DXF(string inputFilePath, ref progressbar)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public static int public_static_int_channels = 1;
public static int public_static_int_sampleRate = 30;
public static string folder_path = "";// Path.GetDirectoryName(inputFilePath);
public static int public_static_int_bytes_per_sample = 2;
public static double public_static_x_shift_for_circular_rendering_for_amplitudes = 0;
public static double public_static_y_shift_for_circular_rendering_for_amplitudes = 30000;
public static double public_static_double___total_durations_in_milliseconds_from_the_samples_rate_and_header_data_for_wave_files = 3;///milliseconds
public static int PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA = 3;//public static async Task FindDataSection(BinaryReader binaryReader)
public static double PUBLIC_STATIC_DOUBLE_TOTAL_SAMPLES_IN_WAV_FILE = 3;
public static double PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING = 1.1;
public static double public_static_double_angle = 0;// i * angleIncrement; // Angle for the current sample
public static double public_static_double_radius = 0;// RToPlot + circlePlotScale; // Radius of the circle for the current sample
public static double public_static_double_radials_x = 0;// radius * Math.Cos(angle * Math.PI / 180); // X coordinate
public static double public_static_double_radials_y = 0;// radius * Math.Sin(angle * Math.PI / 180); // Y coordinate
public static double public_static_double_RToPlot = 3000;
public static double public_static_double_circlePlotScale = 1;
/// RToPlot + circlePlotScale; // Radius of the circle for the current sample
/// int bytesPerSample = 2; // Bytes per sample (16-bit)
/// int samplesPerSecond = 44100; // Sample rate (samples per second)
/// int channelCount = 2; // Number of channels
/// string filePath = "example.wav"; // Path to the WAV file
// Get the file size in bytes
/// long fileSizeInBytes = new FileInfo(filePath).Length;
// Calculate the duration in milliseconds
/// double durationInSeconds = (double)fileSizeInBytes / (bytesPerSample * channelCount * samplesPerSecond);
/// double durationInMilliseconds = durationInSeconds * 1000;
// public static async Task ReadSingleWavFileToConvertItsReportToDxf(string inputFilePath,string folder_path, IProgress<int> progress)
public static async Task ReadSingleWavFileToConvertItsReportToDxf(string inputFilePath, IProgress<int> progress)
{
const int bytesPerSample = 2; // Assuming 16-bit samples
const int bufferSize = 1024 * 1024; // 1MB buffer size
folder_path= Path.GetDirectoryName(inputFilePath);
using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, FileOptions.Asynchronous))
{
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.initialize_dxf_for_sbuilder_for_dxf();
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
// int channels, sampleRate;
int dummy_channel_number = 0;
int dummy_sampleRate = 30;
//////////////////////////////////////////////////////////////////////////////////////////////////
/// await ReadWaveHeader(binaryReader, dummy_channel_number, dummy_sampleRate);
await ReadWaveHeader(inputFilePath);
/// await FindDataSection(binaryReader);/// called inside ReadWaveHeader
//////////////////////////////////////////////////////////////////////////////////////////////////
var tasks = new List<Task>();
for (int channel = 0; channel < public_static_int_channels; channel++)
{
tasks.Add(ReadChannelData(folder_path,inputFilePath, binaryReader, channel, bytesPerSample, public_static_int_sampleRate, progress));
}//for (int channel = 0; channel < channels; channel++)
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
await Task.WhenAll(tasks);
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}//using (FileStream fileStream = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, FileOptions.Asynchronous))
}//public static async Task ReadSingleWavFileToConvertItsReportToDxf(string inputFilePath, IProgress<int> progress)
// Function to find the start of the "data" section in the WAV file
public static async Task FindDataSection(BinaryReader binaryReader)
{
int headerSize = 0;
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
{
string chunkID = new string(binaryReader.ReadChars(4));
int chunkSize = binaryReader.ReadInt32();
if (chunkID == "data")
{
// Found the start of the "data" section
binaryReader.BaseStream.Seek(-8, SeekOrigin.Current); // Move back to the beginning of the chunk
break;
}
else
{
// Skip to the next chunk
binaryReader.BaseStream.Seek(chunkSize, SeekOrigin.Current);
headerSize += 8 + chunkSize; // Update the total header size
}// if (chunkID == "data")
}//while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA = Math.Min(44,headerSize);
/// return headerSize;
}//public static async Task FindDataSection(BinaryReader binaryReader)
// public static async Task ReadWaveHeader(BinaryReader binaryReader, out int public_static_int_channels, out int sampleRate)
//////public static async Task ReadWaveHeader(BinaryReader binaryReader, int local_channel_non_static, int local_sample_rate_data_which_is_non_static)
//////{
////// binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
////// public_static_int_channels = binaryReader.ReadInt16();// this is global data for this class
////// binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
////// public_static_int_sampleRate = binaryReader.ReadInt32();// this is global data for this class
//////}//public static async Task ReadWaveHeader(BinaryReader binaryReader, out int channels, out int sampleRate)
/// <summary>
///
///
///
///
///
/// </summary>
/// <param name="folder_path"></param>
/// <param name="inputFilePath"></param>
/// <param name="binaryReader"></param>
/// <param name="channel"></param>
/// <param name="bytesPerSample"></param>
/// <param name="public_static_int_sampleRate"></param>
/// <param name="progress"></param>
/// <returns></returns>
public static async Task ReadWaveHeader(string filePath)
{
//////// Get the file size in bytes
long fileSizeInBytes = new FileInfo(filePath).Length;
using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
using (BinaryReader binaryReader = new BinaryReader(fileStream))
{
//////////////////////////////////////////////////////
///it gets waiting and not getting proper values within times otherwise ok await FindDataSection(binaryReader);
//////////////////////////////////////////////////////
///
///
int headerSize = 0;
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
{
string chunkID = new string(binaryReader.ReadChars(4));
int chunkSize = binaryReader.ReadInt32();
if (chunkID == "data")
{
// Found the start of the "data" section
binaryReader.BaseStream.Seek(-8, SeekOrigin.Current); // Move back to the beginning of the chunk
// break;
goto goto_here_when_headerSize_found;
}
else
{
// Skip to the next chunk
binaryReader.BaseStream.Seek(chunkSize, SeekOrigin.Current);
headerSize += 8 + chunkSize; // Update the total header size
}//else of if (chunkID == "data")
}//while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
goto_here_when_headerSize_found:;
PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA = Math.Min(44, headerSize);
//////binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
//////int channels = binaryReader.ReadInt16();
//////binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
//////int sampleRate = binaryReader.ReadInt32();
binaryReader.BaseStream.Seek(22, SeekOrigin.Begin); // Move to the 'Channels' field
int channels = binaryReader.ReadInt16();
binaryReader.BaseStream.Seek(24, SeekOrigin.Begin); // Move to the 'SampleRate' field
int sampleRate = binaryReader.ReadInt32();
binaryReader.BaseStream.Seek(34, SeekOrigin.Begin); // Move to the 'BitsPerSample' field
int bytesPerSample = binaryReader.ReadInt16() / 8; // Convert bits per sample to bytes per sample
// Do something with the retrieved channel count and sample rate
// For example, you can assign them to local variables or update global variables
int local_channel_non_static = channels;
public_static_int_channels = channels;
/// int local_sample_rate_data_which_is_non_static = sampleRate;
public_static_int_sampleRate = sampleRate;
public_static_int_bytes_per_sample = bytesPerSample;
//////// Example WAV file properties
/// int bytesPerSample = public_static_int_bytes_per_sample;// 2; // Bytes per sample (16-bit)
int samplesPerSecond = public_static_int_sampleRate;// 44100; // Sample rate (samples per second)
int channelCount = channels;// 2; // Number of channels
//////string filePath = "example.wav"; // Path to the WAV file
//////// Calculate the duration in milliseconds
double durationInSeconds = (double)fileSizeInBytes / (bytesPerSample * channelCount * samplesPerSecond);
double durationInMilliseconds = durationInSeconds * 1000;
//////Console.WriteLine("Duration of the WAV file: " + durationInMilliseconds + " milliseconds");
public_static_double___total_durations_in_milliseconds_from_the_samples_rate_and_header_data_for_wave_files
=
durationInMilliseconds;
///////////////////////////////////////////////////////////////////////////
///
int totalSamples = (int)((fileStream.Length - PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA) / bytesPerSample);
// Calculate the angle increment for each sample
double angleIncrement = Math.Max(360.0 / totalSamples, Double.MinValue);/// 360.0 / totalSamples;
PUBLIC_STATIC_DOUBLE_TOTAL_SAMPLES_IN_WAV_FILE
=
totalSamples;
///////////////////////////////////////////////////////////////////////////
PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING
=
Math.Max( angleIncrement,Double.MinValue);
}//using (BinaryReader binaryReader = new BinaryReader(fileStream))
}// using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
}// public static async Task ReadWaveHeader(string filePath)
public static async Task ReadChannelData(string folder_path,string inputFilePath, BinaryReader binaryReader, int channel, int bytesPerSample, int public_static_int_sampleRate, IProgress<int> progress)
{
try
{
long totalSamples = binaryReader.BaseStream.Length / (public_static_int_channels * bytesPerSample);
int bufferSize = bytesPerSample * public_static_int_channels * 1024; // 1KB buffer size
byte[] buffer = new byte[bufferSize];
StringBuilder internalStringBuilderForDirectFilesAppending = new StringBuilder();
StringBuilder internalStringBuilderForSmallRowsAppending = new StringBuilder();
StringBuilder internalStringBuilderForAmplitudes_circles = new StringBuilder();
internalStringBuilderForAmplitudes_circles.Clear();
long samplesCountForThisChannel = 0;
while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
{
int bytesRead = await binaryReader.BaseStream.ReadAsync(buffer, 0, bufferSize);
for (int i = channel * bytesPerSample; i < bytesRead; i += public_static_int_channels * bytesPerSample)
{
float amplitude = BitConverter.ToInt16(buffer, i) / (float)short.MaxValue;
samplesCountForThisChannel++;
internalStringBuilderForDirectFilesAppending.AppendLine($"{channel},{public_static_int_sampleRate},{Path.GetFileName(inputFilePath)},{samplesCountForThisChannel},{public_static_int_sampleRate},{amplitude:F6}");
internalStringBuilderForSmallRowsAppending.AppendLine($",{channel},{samplesCountForThisChannel},{amplitude:F6}");
/// for references public static double public_static_x_shift_for_circular_rendering_for_amplitudes = 0;
/// for references public static double public_static_y_shift_for_circular_rendering_for_amplitudes = 30000;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////public_static_double___total_durations_in_milliseconds_from_the_samples_rate_and_header_data_for_wave_files
//////////////////////=
//////////////////////durationInMilliseconds;
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////
//////////////////////int totalSamples = (int)((fileStream.Length - PUBLIC_STATIC_INT_HEADER_SIZE_FOUND_UPTO_DATA) / bytesPerSample);
//////////////////////// Calculate the angle increment for each sample
//////////////////////double angleIncrement = 360.0 / totalSamples;
//////////////////////PUBLIC_STATIC_DOUBLE_TOTAL_SAMPLES_IN_WAV_FILE
//////////////////////=
//////////////////////totalSamples;
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING
//////////////////////=
//////////////////////angleIncrement;
///
///
//////public static double PUBLIC_STATIC_DOUBLE_TOTAL_SAMPLES_IN_WAV_FILE = 3;
//////public static double PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING = 0.0000003;
//////public static double public_static_double_angle = 0;// i * angleIncrement; // Angle for the current sample
//////public static double public_static_double_radius = 0;// RToPlot + circlePlotScale; // Radius of the circle for the current sample
//////public static double public_static_double_radials_x = 0;// radius * Math.Cos(angle * Math.PI / 180); // X coordinate
//////public static double public_static_double_radials_y = 0;// radius * Math.Sin(angle * Math.PI / 180); // Y coordinate
public_static_double_angle
=
samplesCountForThisChannel
*
PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING
;
public_static_double_RToPlot = 3000;
public_static_double_circlePlotScale = 1000;
public_static_double_radials_x
=
public_static_x_shift_for_circular_rendering_for_amplitudes
+
public_static_double_RToPlot
*
(Math.Cos(public_static_double_angle * Math.PI / 180));
public_static_double_radials_y
=
public_static_y_shift_for_circular_rendering_for_amplitudes
+
public_static_double_RToPlot
*
(Math.Sin(public_static_double_angle * Math.PI / 180));
///////////////////////////////////////////////////////////////////////////////////
double ___temp_current_radius_for_amplitudes_circles = 0;
___temp_current_radius_for_amplitudes_circles
=
((double)amplitude) * public_static_double_circlePlotScale;
///////////////////////////////////////////////////////////////////////////////////
////// we have checked that non NAN cases are there
internalStringBuilderForAmplitudes_circles.AppendLine($",{channel},{samplesCountForThisChannel},{public_static_x_shift_for_circular_rendering_for_amplitudes},{public_static_y_shift_for_circular_rendering_for_amplitudes},{public_static_double_angle},{PUBLIC_STATIC_DOUBLE___ANGLE_INCREMENTER_FOR_0_TO_360_AMPLITUDES_CIRCLES_PLOTTING}, { amplitude:F6}, {public_static_double_radials_x}, {public_static_double_radials_y},{___temp_current_radius_for_amplitudes_circles}");
///////////////////////////////////////////////////////////////////////////////////
if ( ( !Double.IsNaN(public_static_double_radials_x) ) && (!Double.IsNaN(public_static_double_radials_y)))
{
///////////////////////////////////////////////////////////////////////////////////
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_circle_WITH_BLOCK_LEVEL_COLOR
(
public_static_double_radials_x,
public_static_double_radials_y,
0,
Math.Abs( ___temp_current_radius_for_amplitudes_circles),
"AMPLITUDES_CIRCLE_LAYER",
"XDATA_CHECKING",
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
///////////////////////////////////////////////////////////////////////////////////
}//if( ( !Double.IsNaN(public_static_double_radials_x) ) && (!Double.IsNaN(public_static_double_radials_y)))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_line_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(samplesCountForThisChannel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
,
0
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(samplesCountForThisChannel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
,
0
,
"layer_mods_250_amplitudes_" + (Math.Abs((double)amplitude) * 100000 % 250).ToString()
,
"xdata_checking"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
/// //////this is for the bottom texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(samplesCountForThisChannel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
-
(samplesCountForThisChannel.ToString().Length) * 6
- 30
,
0
,
90
,
6
,
"bottom_text"
,
samplesCountForThisChannel.ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////////////////////////////////////////////////////////////////////// AMPLITUDES DATA ACCUMULATIONS COMPLETE HERE //////
//////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
/////////this is for the top texts on the midlines
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.draw_dxf_text_WITH_BLOCK_LEVEL_COLOR
(
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_X
+
(samplesCountForThisChannel * 10)
,
PUBLIC_STATIC_DOUBLE___SAAN_WAV_SAMPLES_DXF_Y
+
((double)amplitude) * 1000
+
300 * (Math.Sign((double)amplitude))
,
0
,
90
,
6
,
"bottom_text"
,
amplitude.ToString("F6")
// .ToString()
,
"checking_xdata"
,
(int)(Math.Abs((double)amplitude) * 100000 % 250)
);
// Progress reporting
int progressPercentage = (int)((binaryReader.BaseStream.Position / (double)binaryReader.BaseStream.Length) * 100);
progress?.Report(progressPercentage);
}//for (int i = channel * bytesPerSample; i < bytesRead; i += channels * bytesPerSample)
}// while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)
// string folderPath = @"your_folder_path"; // Replace with your folder path
// await File.AppendAllTextAsync(Path.Combine(folderPath, "within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"), internalStringBuilderForDirectFilesAppending.ToString());
// await File.AppendAllTextAsync(Path.Combine(folderPath, "simplest_csv_like_data.txt"), internalStringBuilderForSmallRowsAppending.ToString());
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.finalizer_dxf_for_sbuilder_for_dxf();
//inputFilePath
string folderPath = folder_path;// @"your_folder_path"; // Replace with your folder path
//////using (StreamWriter writer = new StreamWriter(Path.Combine(folderPath, "within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"), true))
//////{
////// await writer.WriteAsync(internalStringBuilderForDirectFilesAppending.ToString());
//////}//using (StreamWriter writer = new StreamWriter(Path.Combine(folderPath, "within_reader_SAAN_SOUNDS_BANKS_COMPILED_output.txt"), true))
//////using (StreamWriter writer = new StreamWriter(Path.Combine(folderPath, "simplest_csv_like_data.txt"), true))
//////{
////// await writer.WriteAsync(internalStringBuilderForSmallRowsAppending.ToString());
//////}//using (StreamWriter writer = new StreamWriter(Path.Combine(folderPath, "simplest_csv_like_data.txt"), true))
//////////////////////////////////////////////////////////////////////////////////////////////////////////// this consumes spaces ////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////// this consumes spaces ////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////// this consumes spaces ////////////////////
using (StreamWriter writer = new StreamWriter(inputFilePath+"_saan_snds_banks.txt", true))
{
await writer.WriteAsync(internalStringBuilderForDirectFilesAppending.ToString());
}//using (StreamWriter writer = new StreamWriter(inputFilePath+"_saan_snds_banks.txt", true))
using (StreamWriter writer = new StreamWriter(inputFilePath+"_simplest_csv_likes_data.txt", true))
{
await writer.WriteAsync(internalStringBuilderForSmallRowsAppending.ToString());
}// using (StreamWriter writer = new StreamWriter(inputFilePath+"_simplest_csv_likes_data.txt", true))
using (StreamWriter writer = new StreamWriter(inputFilePath + "_datas.dxf", true))
{
await writer.WriteAsync
(
SAAGIRID
.ClassToGenerateSAANSAAGIRID_DXF_Reports_26092019
.sbuilder_for_dxf
.ToString()
);
}// using (StreamWriter writer = new StreamWriter(inputFilePath + "_datas.dxf", true))
using (StreamWriter writer = new StreamWriter(inputFilePath + "_amps_circles.txt", true))
{
await writer.WriteAsync
(
internalStringBuilderForAmplitudes_circles
.ToString()
);
}// using (StreamWriter writer = new StreamWriter(inputFilePath + "_amps_circles.txt", true))
//////////////////////////////////////////////////////////////////////////////////////////////////////////// this consumes spaces ////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////// this consumes spaces ////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////// this consumes spaces ////////////////////
}
catch (Exception ___excp___ReadChannelData)
{
System.Windows.Forms.MessageBox.Show("___excp___ReadChannelData = " + ___excp___ReadChannelData.Message + "\r\n" + ___excp___ReadChannelData.StackTrace.ToString());
}//catch(Exception ___excp___ReadChannelData)
}//public static async Task ReadChannelData(BinaryReader binaryReader, int channel, int bytesPerSample, int sampleRate, IProgress<int> progress)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}// public static class PUBLIC_STATIC_CLASS_SAAN_STYLE_WAV_FILES_READERS
}//namespace SAANAUDS.Wave
//////public static void ReadWavFile___USING_SAANSAUDS(string filePath, string outputCsvPath)
////// {
////// using (var reader = new WaveFileReader(filePath))
////// {
////// int sampleRate = reader.WaveFormat.SampleRate;
////// int channels = reader.WaveFormat.Channels;
////// // Output CSV file header
////// using (var writer = new StreamWriter(outputCsvPath))
////// {
////// writer.WriteLine("Track,Sample,Time (microseconds),Amplitude");
////// }//using (var writer = new StreamWriter(outputCsvPath))
////// /// var buffer = new float[reader.WaveFormat.SampleRate * channels]; // Buffer for one second of audio data
////// //reader.Read(buffer, 0, buffer.Length) > 0 this works for the byte array
////// /// this dont work for float array
////// var buffer = new byte[reader.WaveFormat.SampleRate * channels]; // Buffer for one second of audio data
////// while (reader.Read(buffer, 0, buffer.Length) > 0)
////// {
////// // Process the buffer and write to CSV
////// ProcessBufferAndWriteToCsv___USING_SAANSAUDS(buffer, reader, outputCsvPath, sampleRate, channels);
////// }//while (reader.Read(buffer, 0, buffer.Length) > 0)
////// }// using (var reader = new WaveFileReader(filePath))
////// }//public static void ReadWavFile___USING_SAANSAUDS(string filePath, string outputCsvPath)
//////// public static void ProcessBufferAndWriteToCsv___USING_SAANSAUDS(float[] buffer, WaveFileReader reader, string outputCsvPath, int sampleRate, int channels)
//////public static void ProcessBufferAndWriteToCsv___USING_SAANSAUDS(byte[] buffer, WaveFileReader reader, string outputCsvPath, int sampleRate, int channels)
////// {
////// // Calculate the time step between samples in microseconds
////// double timeStepMicroseconds = 1e6 / sampleRate;
//////Please explain this code double timeStepMicroseconds = 1e6 / sampleRate;
//////Certainly!The code double timeStepMicroseconds = 1e6 / sampleRate; calculates the time interval, in microseconds, between consecutive samples in a digital audio signal. Let's break it down:
//////1e6: This is a shorthand notation for 1 multiplied by 10 to the power of 6, which is equivalent to 1, 000, 000.In this context, it represents the number of microseconds in a second.
//////sampleRate: This variable typically represents the number of samples per second in a digital audio signal.It is a key parameter that defines how many individual measurements or samples are taken within one second of audio.
//////1e6 / sampleRate: This expression calculates the time interval between consecutive samples in microseconds.By dividing 1, 000, 000 microseconds(1 second) by the sample rate, you get the time duration for each sample in microseconds.
//////double timeStepMicroseconds: This variable stores the result of the calculation, representing the time interval between consecutive samples in microseconds.It is declared as a double to handle fractional values that may arise from the division.
//////In summary, timeStepMicroseconds is a variable that holds the duration, in microseconds, between each sample in a digital audio signal.It is derived from the reciprocal of the sample rate, indicating the time it takes to capture each individual sample in the signal.This value is crucial in various audio processing and analysis tasks, such as determining the time between samples or setting up time - based operations on the audio data.
////// int samples = buffer.Length / channels;
////// using (var writer = new StreamWriter(outputCsvPath, true)) // Append to existing CSV file
////// {
////// for (int i = 0; i < samples; i++)
////// {
////// // Calculate the time in microseconds
////// double timeMicroseconds = i * timeStepMicroseconds;
////// for (int channel = 0; channel < channels; channel++)
////// {
////// float amplitude = buffer[i * channels + channel];
////// // Write data to CSV
////// writer.WriteLine($"{channel + 1},{i + 1},{timeMicroseconds},{amplitude}");
////// }//for (int channel = 0; channel < channels; channel++)
////// }//for (int i = 0; i < samples; i++)
////// }//using (var writer = new StreamWriter(outputCsvPath, true)) // Append to existing CSV file
////// }//public static void ProcessBufferAndWriteToCsv___USING_SAANSAUDS(float[] buffer, WaveFileReader reader, string outputCsvPath, int sampleRate, int channels)
//////static int GetWavHeaderSize(string filePath)
////// {
////// using (var waveReader = new WaveFileReader(filePath))
////// {
////// // Calculate the header size
////// int headerSize = (int)(waveReader.Position - waveReader.Length);
////// return Math.Max(headerSize, 0); // Ensure the header size is non-negative
////// }
////// }
///
//////#region Assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//////// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll
//////#endregion
//////using System.Security;
//////namespace System
//////{
////// //
////// // Summary:
////// // Converts base data types to an array of bytes, and an array of bytes to base
////// // data types.
////// public static class BitConverter
////// {
////// //
////// // Summary:
////// // Indicates the byte order ("endianness") in which data is stored in this computer
////// // architecture.
////// //
////// // Returns:
////// // true if the architecture is little-endian; false if it is big-endian.
////// public static readonly bool IsLittleEndian;
////// //
////// // Summary:
////// // Converts the specified double-precision floating point number to a 64-bit signed
////// // integer.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // A 64-bit signed integer whose value is equivalent to value.
////// [SecuritySafeCritical]
////// public static long DoubleToInt64Bits(double value);
////// //
////// // Summary:
////// // Returns the specified Boolean value as a byte array.
////// //
////// // Parameters:
////// // value:
////// // A Boolean value.
////// //
////// // Returns:
////// // A byte array with length 1.
////// public static byte[] GetBytes(bool value);
////// //
////// // Summary:
////// // Returns the specified Unicode character value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // A character to convert.
////// //
////// // Returns:
////// // An array of bytes with length 2.
////// public static byte[] GetBytes(char value);
////// //
////// // Summary:
////// // Returns the specified 16-bit signed integer value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 2.
////// [SecuritySafeCritical]
////// public static byte[] GetBytes(short value);
////// //
////// // Summary:
////// // Returns the specified 32-bit signed integer value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 4.
////// [SecuritySafeCritical]
////// public static byte[] GetBytes(int value);
////// //
////// // Summary:
////// // Returns the specified 64-bit signed integer value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 8.
////// [SecuritySafeCritical]
////// public static byte[] GetBytes(long value);
////// //
////// // Summary:
////// // Returns the specified 16-bit unsigned integer value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 2.
////// [CLSCompliant(false)]
////// public static byte[] GetBytes(ushort value);
////// //
////// // Summary:
////// // Returns the specified 32-bit unsigned integer value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 4.
////// [CLSCompliant(false)]
////// public static byte[] GetBytes(uint value);
////// //
////// // Summary:
////// // Returns the specified 64-bit unsigned integer value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 8.
////// [CLSCompliant(false)]
////// public static byte[] GetBytes(ulong value);
////// //
////// // Summary:
////// // Returns the specified single-precision floating point value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 4.
////// [SecuritySafeCritical]
////// public static byte[] GetBytes(float value);
////// //
////// // Summary:
////// // Returns the specified double-precision floating point value as an array of bytes.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // An array of bytes with length 8.
////// [SecuritySafeCritical]
////// public static byte[] GetBytes(double value);
////// //
////// // Summary:
////// // Converts the specified 64-bit signed integer to a double-precision floating point
////// // number.
////// //
////// // Parameters:
////// // value:
////// // The number to convert.
////// //
////// // Returns:
////// // A double-precision floating point number whose value is equivalent to value.
////// [SecuritySafeCritical]
////// public static double Int64BitsToDouble(long value);
////// //
////// // Summary:
////// // Returns a Boolean value converted from the byte at a specified position in a
////// // byte array.
////// //
////// // Parameters:
////// // value:
////// // A byte array.
////// //
////// // startIndex:
////// // The index of the byte within value.
////// //
////// // Returns:
////// // true if the byte at startIndex in value is nonzero; otherwise, false.
////// //
////// // Exceptions:
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// public static bool ToBoolean(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a Unicode character converted from two bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A character formed by two bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex equals the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// public static char ToChar(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a double-precision floating point number converted from eight bytes at
////// // a specified position in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A double precision floating point number formed by eight bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex is greater than or equal to the length of value minus 7, and is less
////// // than or equal to the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [SecuritySafeCritical]
////// public static double ToDouble(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a 16-bit signed integer converted from two bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A 16-bit signed integer formed by two bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex equals the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [SecuritySafeCritical]
////// public static short ToInt16(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a 32-bit signed integer converted from four bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A 32-bit signed integer formed by four bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex is greater than or equal to the length of value minus 3, and is less
////// // than or equal to the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [SecuritySafeCritical]
////// public static int ToInt32(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a 64-bit signed integer converted from eight bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A 64-bit signed integer formed by eight bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex is greater than or equal to the length of value minus 7, and is less
////// // than or equal to the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [SecuritySafeCritical]
////// public static long ToInt64(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a single-precision floating point number converted from four bytes at
////// // a specified position in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A single-precision floating point number formed by four bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex is greater than or equal to the length of value minus 3, and is less
////// // than or equal to the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [SecuritySafeCritical]
////// public static float ToSingle(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Converts the numeric value of each element of a specified subarray of bytes to
////// // its equivalent hexadecimal string representation.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // length:
////// // The number of array elements in value to convert.
////// //
////// // Returns:
////// // A string of hexadecimal pairs separated by hyphens, where each pair represents
////// // the corresponding element in a subarray of value; for example, "7F-2C-4A-00".
////// //
////// // Exceptions:
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex or length is less than zero.-or- startIndex is greater than zero and
////// // is greater than or equal to the length of value.
////// //
////// // T:System.ArgumentException:
////// // The combination of startIndex and length does not specify a position within value;
////// // that is, the startIndex parameter is greater than the length of value minus the
////// // length parameter.
////// public static string ToString(byte[] value, int startIndex, int length);
////// //
////// // Summary:
////// // Converts the numeric value of each element of a specified array of bytes to its
////// // equivalent hexadecimal string representation.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // Returns:
////// // A string of hexadecimal pairs separated by hyphens, where each pair represents
////// // the corresponding element in value; for example, "7F-2C-4A-00".
////// //
////// // Exceptions:
////// // T:System.ArgumentNullException:
////// // value is null.
////// public static string ToString(byte[] value);
////// //
////// // Summary:
////// // Converts the numeric value of each element of a specified subarray of bytes to
////// // its equivalent hexadecimal string representation.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A string of hexadecimal pairs separated by hyphens, where each pair represents
////// // the corresponding element in a subarray of value; for example, "7F-2C-4A-00".
////// //
////// // Exceptions:
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// public static string ToString(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a 16-bit unsigned integer converted from two bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // The array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A 16-bit unsigned integer formed by two bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex equals the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [CLSCompliant(false)]
////// public static ushort ToUInt16(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a 32-bit unsigned integer converted from four bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A 32-bit unsigned integer formed by four bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex is greater than or equal to the length of value minus 3, and is less
////// // than or equal to the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [CLSCompliant(false)]
////// public static uint ToUInt32(byte[] value, int startIndex);
////// //
////// // Summary:
////// // Returns a 64-bit unsigned integer converted from eight bytes at a specified position
////// // in a byte array.
////// //
////// // Parameters:
////// // value:
////// // An array of bytes.
////// //
////// // startIndex:
////// // The starting position within value.
////// //
////// // Returns:
////// // A 64-bit unsigned integer formed by the eight bytes beginning at startIndex.
////// //
////// // Exceptions:
////// // T:System.ArgumentException:
////// // startIndex is greater than or equal to the length of value minus 7, and is less
////// // than or equal to the length of value minus 1.
////// //
////// // T:System.ArgumentNullException:
////// // value is null.
////// //
////// // T:System.ArgumentOutOfRangeException:
////// // startIndex is less than zero or greater than the length of value minus 1.
////// [CLSCompliant(false)]
////// public static ulong ToUInt64(byte[] value, int startIndex);
////// }
//////}
No comments:
Post a Comment