// https://github.com/xiph/opus/issues/42 w public VoiceClient(SampleRate sampleRate = SampleRate._48k, Bitrate bitRate = Bitrate._192k, Channels channels = Channels.Two, FrameDelay frameDelay = FrameDelay.Delay20, BitDepthEnum bitDepthEnum = BitDepthEnum.Float32) { this.frameDelay = (int)frameDelay; this.sampleRate = (int)sampleRate; this.bitRate = (int)bitRate; this.channels = (int)channels; this.bitDepth = (int)bitDepthEnum; this.Encoder = new LibOpusEncoder(this.sampleRate, this.channels, this.bitRate, this.frameDelay); Encode = bitDepthEnum switch { BitDepthEnum.Float32 => Encoder.EncodeFloat, BitDepthEnum.UInt16 => Encoder.Encode, _ => throw new NotSupportedException(nameof(BitDepth)) }; if (bitDepthEnum == BitDepthEnum.Float32) { Encode = Encoder.EncodeFloat; } else { Encode = Encoder.Encode; } _arrayPool = ArrayPool <byte> .Shared; }
public void add(int rate) { SampleRate samplerate = new SampleRate(); samplerate.Rate = rate; this.rates.Add(samplerate); }
public void SaveToFile(string filename) { FileStream fs = new FileStream(filename, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.WriteLine("SPINDELANALYSE"); sw.WriteLine("Sample Rate for EEG:;" + SampleRate.ToString()); sw.WriteLine("Startklokkeslett for EEG:;" + StartTime.ToString("HH:mm:ss")); sw.WriteLine("Gjennomsnittlig spindelvarighet:;" + AverageSpindleDuration.ToString(CultureInfo.InvariantCulture)); sw.WriteLine("Gjennomsnittlig spindelfrekvens:;" + AverageSpindleFrequency.ToString(CultureInfo.InvariantCulture)); sw.WriteLine("Median av medianspindelfrekvens:;" + MedianSpindleFrequency.ToString(CultureInfo.InvariantCulture)); sw.WriteLine("Avledning med mest tydelige spindler:;" + MostSignificantChannel); sw.WriteLine("Antall spindler per 30 sekunder sovn:;" + SpindleDensity.ToString(CultureInfo.InvariantCulture)); sw.WriteLine("Andel av sovn som er sovnspindel:;" + SpindleRatio.ToString(CultureInfo.InvariantCulture)); sw.WriteLine(); sw.WriteLine("Spindelnummer;Starttidspunkt;Varighet;Snittfrekvens;Medianfrekvens;Sees best i avledning;Frekvens i beste avledning"); for (int i = 0; i < SleepSpindles.Count; i++) { sw.Write((i + 1).ToString() + ";"); SleepSpindles[i].WriteToStream(sw); sw.WriteLine(); } sw.Close(); }
// Full constructor takes Capture instance and specific values for // channels, bits, and samples. internal SoundFormat(Capture captureDevice, SampleRate rate, SampleSize size, short channels) { if (captureDevice == null) { throw new ArgumentNullException("captureDevice"); } this._captureDevice = captureDevice; try { // Test the supplied format characteristics. this._currentFormat = ConstructFormat((int)rate, (short)size, (short)channels); } catch (Exception ex) { string errMsg = string.Format("Sound format not supported: {0} samples/sec, {1} bits/sample, {2} channels.", (int)rate, (short)size, (short)channels); throw new Exception(errMsg, ex); } this._channels = channels; this._bitsPerSample = (short)size; this._samplesPerSecond = (int)rate; }
public override int GetHashCode() { int hash = 1; if (Timestamp != 0L) { hash ^= Timestamp.GetHashCode(); } if (SampleRate != 0) { hash ^= SampleRate.GetHashCode(); } if (Channels != 0) { hash ^= Channels.GetHashCode(); } if (BitsPerSample != 0) { hash ^= BitsPerSample.GetHashCode(); } if (Data.Length != 0) { hash ^= Data.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void GetEnumerables() { SampleRate.Add(AudioSampleRate.Default.ToString()); SampleRate.Add(AudioSampleRate.Hz22050.ToString()); SampleRate.Add(AudioSampleRate.Hz44100.ToString()); SampleRate.Add(AudioSampleRate.Hz48000.ToString()); }
public MipChannel(MipTypes.ChannelField channelField, SampleRate sampleRate) : this(msclPINVOKE.new_MipChannel__SWIG_0((int)channelField, SampleRate.getCPtr(sampleRate)), true) { if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// Add time-series data to the channel. /// </summary> /// <param name="sensorName">sensor containing the channel to add data to.</param> /// <param name="channelName">channel to add data to.</param> /// <param name="sampleRate">sample-rate for points in data</param> /// <param name="data">a list of points to add to the channel. /// <remarks>The points should be ordered and match the sample-rate provided.</remarks> /// </param> public void AddTimeSeriesData(SampleRate sampleRate, IEnumerable<Point> data) { var payload = new MemoryStream(); var xdr = new XdrWriter(payload); const int VERSION = 1; xdr.WriteInt(VERSION); xdr.WriteInt(sampleRate.Type.ToXdr()); xdr.WriteInt(sampleRate.Rate); //Writing an array in XDR. an array is always prefixed by the array length xdr.WriteInt(data.Count()); foreach (Point p in data) { xdr.WriteUnsingedHyper(p.UnixTimestamp); xdr.WriteFloat(p.Value); } string url = "/sensors/" + _sensorName + "/channels/" + this.Name + "/streams/timeseries/data/"; var request = _requests.url(url) .Param("version", "1") .ContentType("application/xdr") .Data(payload.ToArray()) .Put(); // check the response code for success if (request.ResponseCode != HttpStatusCode.Created) { throw SensorCloudException.GenerateSensorCloudException(request, "AddTimeSeriesData failed."); } }
public void ConversionTest( string inputPath, SampleRate sampleRate, BitRate bitRate, ChannelFormat channelFormat) { var inputFileName = Path.GetFileNameWithoutExtension(inputPath); var actualSampleRate = SampleRateHelper.GetSampleRate(sampleRate); var actualBitRate = BitRateHelper.GetBitRate(bitRate); var actualChannelsCount = ChannelFormatHelper.GetChannelsCount(channelFormat); var fileName = $"{inputFileName}-SR{actualSampleRate}-BR{actualBitRate}-CF{actualChannelsCount}"; var outputPath = string.Format(OutputPathFormat, fileName); WavConverter.Convert(inputPath, outputPath, sampleRate, channelFormat, bitRate); using (var inputReader = new AudioFileReader(inputPath)) using (var outputReader = new WaveFileReader(outputPath)) { Assert.Equal(actualSampleRate, outputReader.WaveFormat.SampleRate); Assert.Equal(actualBitRate, outputReader.WaveFormat.BitsPerSample); Assert.Equal(actualChannelsCount, outputReader.WaveFormat.Channels); Assert.InRange( inputReader.TotalTime, outputReader.TotalTime - _totalTimeDelta, outputReader.TotalTime + _totalTimeDelta); } #if !DEBUG DeleteIfExists(outputPath); #endif }
public void Reduce_Tests() { SampleRate rate = new SampleRate(96, 4.0); SampleRate expected = new SampleRate(24, 1.0); SampleRate actual = rate.Reduce(); Assert.AreEqual(expected, actual); rate = new SampleRate(100, 6.0); expected = new SampleRate(50, 3.0); actual = rate.Reduce(); Assert.AreEqual(expected, actual); rate = new SampleRate(100, 2.5); expected = new SampleRate(40, 1); actual = rate.Reduce(); Assert.AreEqual(expected, actual); rate = new SampleRate(100, 0.5); expected = new SampleRate(100, 0.5); actual = rate.Reduce(); Assert.AreEqual(expected, actual); rate = new SampleRate(30000, 1001); // NTSC expected = new SampleRate(30000, 1001); actual = rate.Reduce(); Assert.AreEqual(expected, actual); rate = new SampleRate(24000, 1001); // Film expected = new SampleRate(24000, 1001); actual = rate.Reduce(); Assert.AreEqual(expected, actual); }
public Daisy3_Import(string bookfile, string outDir, bool skipACM, SampleRate audioProjectSampleRate, bool stereo, bool autoDetectPcmFormat, bool xukPrettyFormat) { m_XukPrettyFormat = xukPrettyFormat; m_SkipACM = skipACM; m_audioProjectSampleRate = audioProjectSampleRate; m_audioStereo = stereo; m_autoDetectPcmFormat = autoDetectPcmFormat; reportProgress(10, UrakawaSDK_daisy_Lang.InitializeImport); m_PackageUniqueIdAttr = null; m_Book_FilePath = bookfile; m_outDirectory = outDir; if (!m_outDirectory.EndsWith("" + Path.DirectorySeparatorChar)) { m_outDirectory += Path.DirectorySeparatorChar; } if (!Directory.Exists(m_outDirectory)) { FileDataProvider.CreateDirectory(m_outDirectory); } m_Xuk_FilePath = GetXukFilePath(m_outDirectory, m_Book_FilePath, null, false); if (RequestCancellation) { return; } //initializeProject(); //reportProgress(100, UrakawaSDK_daisy_Lang.ImportInitialized); }
public WaveOutStream(int device, AudioBits quality, AudioMode mode, SampleRate rate) : base() { _Format = new WaveFormat((short)mode, (int)rate, (short)quality); this._BaseStream = new MemoryStream(this.InitialCapacity); Init(); }
public StructuralHealth(float angle, uint uptime, float damage, SampleRate processingRate, Histogram histogram) : this(msclPINVOKE.new_StructuralHealth(angle, uptime, damage, SampleRate.getCPtr(processingRate), Histogram.getCPtr(histogram)), true) { if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } }
public override int GetHashCode() { unchecked { var hashCode = TrackId; hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Artist != null ? Artist.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AlbumArtist != null ? AlbumArtist.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Composer != null ? Composer.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Album != null ? Album.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Genre != null ? Genre.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Kind != null ? Kind.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Size.GetHashCode(); hashCode = (hashCode * 397) ^ (PlayingTime != null ? PlayingTime.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TrackNumber.GetHashCode(); hashCode = (hashCode * 397) ^ Year.GetHashCode(); hashCode = (hashCode * 397) ^ DateModified.GetHashCode(); hashCode = (hashCode * 397) ^ DateAdded.GetHashCode(); hashCode = (hashCode * 397) ^ BitRate.GetHashCode(); hashCode = (hashCode * 397) ^ SampleRate.GetHashCode(); hashCode = (hashCode * 397) ^ PlayCount.GetHashCode(); hashCode = (hashCode * 397) ^ PlayDate.GetHashCode(); hashCode = (hashCode * 397) ^ PartOfCompilation.GetHashCode(); return(hashCode); } }
static public void SetSampleRate(SampleRate sr) { if (Msp430 != null) { byte val = (sr == SampleRate.Slow ? (byte)0 : (byte)1); USBSendData(new byte[] { 0x06, val }); } }
public static void CreateMonoWAVFile(string filePath, SampleRate sampleRate, WaveChunk wave) { FileStream stream = new FileStream(filePath, FileMode.Create); BinaryWriter writer = new BinaryWriter(stream, Encoding.ASCII); WriteToStream(writer, sampleRate, wave); writer.Close(); }
public WaveFormatExtensible(SampleRate rate, BitDepth bits, SpeakerConfiguration channelMask, Guid subFormat) : base(rate, bits, channelMask, WaveFormatEncoding.Extensible, Marshal.SizeOf(typeof(WaveFormatExtensible))) { wValidBitsPerSample = (short)bits; dwChannelMask = (int)channelMask; this.subFormat = subFormat; }
public void ParseTest() { const string str = @" 0 , 1360"; var sampleRate = new SampleRate(str); Assert.That(sampleRate.SamplingFrequency, Is.EqualTo(0).Within(0.1)); Assert.That(sampleRate.LastSampleNumber, Is.EqualTo(1360)); }
/// <summary> /// This constructor will create an empty .wav container to be filled with user data. /// </summary> public WavFormatManager() { this.channelCount = 0; this.channelLeft = null; this.channelRight = null; this.sampleRate = SampleRate.NullSampleRate; this.bitsPerSample = 0; }
static void Main(string[] args) { System.Console.WriteLine("Connecting to SensorCloud"); var device = new SensorCloud.Device("YOUR_DEVICE_ID", "YOUR_DEVICE_OPEN_API_KEY_HERE"); string sensorName = "sensor1"; string channelName = "ch1"; Sensor sensor = null; if (device.HasSensor(sensorName)) { System.Console.WriteLine("getting sensor " + sensorName); sensor = device.GetSensor(sensorName); } else { System.Console.WriteLine("Adding sensor " + sensorName); sensor = device.AddSensor(sensorName); } Channel channel = null; if (sensor.HasChannel(channelName)) { System.Console.WriteLine("getting channel " + channelName); channel = sensor.GetChannel(channelName); } else { System.Console.WriteLine("Adding channel " + channelName); channel = sensor.AddChannel(channelName); } //create a 5000 point sine wave with a samplerate of 1 Hz, using a now as the starttime var data = new List <Point>(); var timestamp = DateTime.Now; var samplerate = SampleRate.Hertz(1); TimeSpan interval = samplerate.Interval(); for (int i = 0; i < 5000; i++) { timestamp += interval; //Generate a sine wave float value = (float)Math.Sin((timestamp.Ticks / interval.Ticks) * 0.1); data.Add(new Point(timestamp, value)); } System.Console.Write("uploading " + data.Count + " datapoins..."); channel.AddTimeSeriesData(samplerate, data); System.Console.WriteLine("complete"); System.Console.WriteLine("\npress any key to exit"); System.Console.ReadKey(); }
public Form1() { InitializeComponent(); for (int i = 1; i <= 16; i++) { checkedListBox1.Items.Add(i, false); } txRate.Text = SampleRate.ToString(); }
public static void WriteToStream(BinaryWriter writer, SampleRate sampleRate, WaveChunk wave) { WAVGenerator generator = Singleton.SetAudioProperties((uint)sampleRate, 1); var data = WaveChunk.Get16BitArray(wave); generator.SetMonoData(data); generator.SaveToFile(writer); }
/// <summary> /// Updates the sample rate without modufying the audio buffers. /// </summary> /// <param name="value">Desired sample rate.</param> public void SetSampleRate(SampleRate value) { if (value == SampleRate.NullSampleRate) { throw new Exception("Can't set the sample rate to null."); } this.sampleRate = value; }
public virtual WirelessTypes.Filter minLowPassFilter(SampleRate rate) { WirelessTypes.Filter ret = (WirelessTypes.Filter)msclPINVOKE.NodeFeatures_minLowPassFilter(swigCPtr, SampleRate.getCPtr(rate)); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual WirelessTypes.SettlingTime maxFilterSettlingTime(SampleRate rate) { WirelessTypes.SettlingTime ret = (WirelessTypes.SettlingTime)msclPINVOKE.NodeFeatures_maxFilterSettlingTime(swigCPtr, SampleRate.getCPtr(rate)); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SampleRate validateSampleRate(ushort sampleRateBase) { SampleRate ret = new SampleRate(msclPINVOKE.MipChannel_validateSampleRate__SWIG_0(swigCPtr, sampleRateBase), false); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SampleRate sampleRate() { SampleRate ret = new SampleRate(msclPINVOKE.MipChannel_sampleRate(swigCPtr), false); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SampleRate validateSampleRate(InertialNode node) { SampleRate ret = new SampleRate(msclPINVOKE.MipChannel_validateSampleRate__SWIG_1(swigCPtr, InertialNode.getCPtr(node)), false); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SampleRate processingRate() { SampleRate ret = new SampleRate(msclPINVOKE.StructuralHealth_processingRate(swigCPtr), false); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SampleRate sampleRate() { SampleRate ret = new SampleRate(msclPINVOKE.DataSweep_sampleRate(swigCPtr), true); if (msclPINVOKE.SWIGPendingException.Pending) { throw msclPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public MegaVoiceExport(ObiPresentation presentation, string exportDirectory, List <string> navListElementNamesList, bool encodeToMp3, double mp3BitRate, SampleRate sampleRate, bool stereo, bool skipACM, int audioFileSectionLevel, string megaVoiceExportPath) : base(presentation, exportDirectory, navListElementNamesList, encodeToMp3, mp3BitRate, sampleRate, stereo, skipACM, audioFileSectionLevel) { m_Filename_Content = null; m_AudioFileSectionLevel = audioFileSectionLevel; GeneratorName = "Obi"; m_MegaVoiceExportPath = megaVoiceExportPath; }
/// <summary> /// Creates a new song with a 3/4 measure size, a tempo of 240 quarter-notes per minute, /// mezzo-forte prevailing dynamic level, using a basic note timbre and the specified /// audio format settings. /// </summary> /// <param name="sampleRate">Desired sample rate</param> /// <param name="bitsPerSample">Desired bits-per-sample</param> /// <param name="channels">Desired data channels</param> public Song(SampleRate sampleRate, BitsPerSample bitsPerSample, DataChannels channels) : base(sampleRate, bitsPerSample, channels) { m_measureSize = new MeasureSize(3, NoteValue.Quarter); m_tempo = new Tempo(240, NoteValue.Quarter); m_dynamic = (double)Music.Dynamic.MezzoForte / 100.0D; m_timbre = Music.Timbre.BasicNote; m_damping = Music.Damping.Natural; m_noteQueue = new List<Note>(); }
public WaveFile(SampleRate sampleRate, BitsPerSample bitsPerSample, DataChannels channels, WaveFormat audioFormat) : this((int)sampleRate, (short)bitsPerSample, (short)channels, (ushort)audioFormat) { }
/// <summary> /// Creates a new empty in-memory wave file in Pulse Code Modulation (PCM) audio format. /// </summary> /// <param name="sampleRate">Desired sample rate.</param> /// <param name="bitsPerSample">Desired bits-per-sample.</param> /// <param name="channels">Desired data channels.</param> public WaveFile(SampleRate sampleRate, BitsPerSample bitsPerSample, DataChannels channels) : this((int)sampleRate, (short)bitsPerSample, (short)channels, (ushort)WaveFormat.PCM) { }
public SynthVoice(SampleRate sampleRate, StereoBuffer buffer) : base(sampleRate, buffer) { Initialize(sampleRate, buffer); }
public SynthVoice(SampleRate sampleRate, StereoBuffer buffer, string name) : base(sampleRate, buffer, name) { Initialize(sampleRate, buffer); }
private void Initialize(SampleRate sampleRate, StereoBuffer buffer) { emptyFMModulator = new EmptyMonoComponent(sampleRate, new MonoBuffer(0)); slewLimiter = new SlewLimiter(sampleRate, new MonoBuffer(0), "Portamento"); slewLimiter.SynthesizeReplaceEnabled = true; envelope1 = new AdsrEnvelope(sampleRate, new MonoBuffer(0), "Envelope 1"); envelope1.SynthesizeReplaceEnabled = true; envelope2 = new AdsrEnvelope(sampleRate, new MonoBuffer(0), "Envelope 2"); envelope2.SynthesizeReplaceEnabled = true; lfo1 = new Lfo(sampleRate, new MonoBuffer(0), "LFO 1"); lfo1.SynthesizeReplaceEnabled = true; lfo2 = new Lfo(sampleRate, new MonoBuffer(0), "LFO 2"); lfo2.SynthesizeReplaceEnabled = true; Wavetable wave = Wavetable.Load("Sawtooth"); osc1 = new Oscillator(sampleRate, new MonoBuffer(0), "Oscillator 1", wave, emptyFMModulator, slewLimiter); osc1.SynthesizeReplaceEnabled = true; osc2 = new Oscillator(sampleRate, new MonoBuffer(0), "Oscillator 2", wave, emptyFMModulator, slewLimiter); osc2.SynthesizeReplaceEnabled = true; filter = new StateVariableFilter(sampleRate, new MonoBuffer(0), "State Variable Filter", osc1, osc2, envelope2, lfo2, envelope1); filter.SynthesizeReplaceEnabled = true; converter = new MonoToStereoConverter(sampleRate, buffer, filter); converter.SynthesizeReplaceEnabled = false; oscWaveProgrammer1 = new OscWaveProgrammer("Oscillator 1", osc1); oscWaveProgrammer2 = new OscWaveProgrammer("Oscillator 2", osc2); oscFMProgrammer1 = new OscFMProgrammer("Oscillator 1", osc1, emptyFMModulator, envelope1, envelope2, lfo1, lfo2); oscFMProgrammer2 = new OscFMProgrammer("Oscillator 2", osc2, emptyFMModulator, envelope1, envelope2, lfo1, lfo2); AddComponent(emptyFMModulator); AddComponent(slewLimiter); AddComponent(osc1); AddComponent(osc2); AddComponent(envelope1); AddComponent(envelope2); AddComponent(lfo1); AddComponent(lfo2); AddComponent(filter); AddComponent(converter); AddParameters(slewLimiter); AddParameters(osc1); AddParameters(oscWaveProgrammer1); AddParameters(oscFMProgrammer1); AddParameters(osc2); AddParameters(oscWaveProgrammer2); AddParameters(oscFMProgrammer2); AddParameters(envelope1); AddParameters(envelope2); AddParameters(lfo1); AddParameters(lfo2); AddParameters(filter); AddBendable(osc1); AddBendable(osc2); AddControllable(lfo1); AddControllable(lfo2); }
/// <summary> /// Set the sample rate for capture /// </summary> /// <param name="sample_rate">Sample rate to set</param> public void SetSampleRate(SampleRate sample_rate) { String export_command = set_sample_rate_cmd + ", "; export_command += sample_rate.DigitalSampleRate.ToString(); export_command += ", " + sample_rate.AnalogSampleRate.ToString(); WriteString(export_command); String response = ""; GetResponse(ref response); }