/* * Adds a waveform group for a Wav file to a Dataset */ private bool InsertWaveStream(ref DicomDataSet InDS, string strInputWaveFileName) { DicomWaveformGroup AudioWaveformGroup = new DicomWaveformGroup(); int nNumberOfChannels = 0; // Load an audio file into the waveform group try { AudioWaveformGroup.LoadAudio(strInputWaveFileName); } catch (Exception ex) { MessageBox.Show("Couldn't insert the wave stream into the dataset.\r\n\r\n" + ex.ToString()); return(false); } // Verify that hte frequency is 8K int nSamplingFrequency = (int)AudioWaveformGroup.GetSamplingFrequency(); if (nSamplingFrequency != 8000) { MessageBox.Show("The samples per second (sampling rate) for the wave file should be 8KHz."); return(false); } // Set the channel source nNumberOfChannels = AudioWaveformGroup.ChannelCount; if (nNumberOfChannels > 0) { DicomWaveformChannel channel = null; DicomCodeSequenceItem DicomSourceSequenceItem = new DicomCodeSequenceItem(); DicomSourceSequenceItem.CodeMeaning = "Dictation"; DicomSourceSequenceItem.CodeValue = "110011"; DicomSourceSequenceItem.CodingSchemeDesignator = "DCM"; DicomSourceSequenceItem.CodingSchemeVersion = "01"; for (int nIndex = 0; nIndex < nNumberOfChannels; nIndex++) { channel = AudioWaveformGroup.GetChannel(nIndex); if (channel != null) { try { channel.SetChannelSource(DicomSourceSequenceItem); } catch (Exception ex) { MessageBox.Show("Couldn't set the channel source\r\n\r\n" + ex.ToString()); return(false); } } } } // Insert the waveform group into the dataset try { InDS.AddWaveformGroup(AudioWaveformGroup, 0); } catch (Exception ex) { MessageBox.Show("Couldn't insert the wave stream into the dataset.\r\n\r\n" + ex.ToString()); return(false); } return(true); }