Helper class for sample rates.
コード例 #1
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
 public SampleRates(SampleRates other) : this(msclPINVOKE.new_SampleRates__SWIG_1(SampleRates.getCPtr(other)), true)
 {
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #2
0
 public void Reset()
 {
     _FFTWindow  = FFTWindow.BlackmanHarris;
     _FFTSamples = FFTSamples._8192;
     _sampleRate = SampleRates._44100Hz;
     _channels   = Channels.ALL;
 }
コード例 #3
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
 public SampleRatesEnumerator(SampleRates collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
コード例 #4
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
 public void AddRange(SampleRates values)
 {
     msclPINVOKE.SampleRates_AddRange(swigCPtr, SampleRates.getCPtr(values));
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #5
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
 public void SetRange(int index, SampleRates values)
 {
     msclPINVOKE.SampleRates_SetRange(swigCPtr, index, SampleRates.getCPtr(values));
     if (msclPINVOKE.SWIGPendingException.Pending)
     {
         throw msclPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #6
0
            public void Process(SampleRates inputSampleRate, float[] input, float[] output)
            {
                var result = Dissonance_PreprocessCaptureFrame(_handle, (int)inputSampleRate, input, output);

                if (result != ProcessorErrors.Ok)
                {
                    throw new DissonanceException(Log.PossibleBugMessage(string.Format("Preprocessor error: '{0}'", result), "0A89A5E7-F527-4856-BA01-5A19578C6D88"));
                }
            }
コード例 #7
0
        public SampleRates supportedSampleRates(MipTypes.DataClass dataClass)
        {
            SampleRates ret = new SampleRates(msclPINVOKE.MipNodeFeatures_supportedSampleRates(swigCPtr, (int)dataClass), false);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #8
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
        public static SampleRates Repeat(SampleRate value, int count)
        {
            global::System.IntPtr cPtr = msclPINVOKE.SampleRates_Repeat(SampleRate.getCPtr(value), count);
            SampleRates           ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SampleRates(cPtr, true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #9
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
        public SampleRates GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = msclPINVOKE.SampleRates_GetRange(swigCPtr, index, count);
            SampleRates           ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SampleRates(cPtr, true);

            if (msclPINVOKE.SWIGPendingException.Pending)
            {
                throw msclPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #10
0
        public override void DrawRuleGUI()
        {
            base.DrawRuleGUI();
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Audio Import Settings", EditorStyles.boldLabel);
            EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 2), QuickEditorColors.DarkGrayX11);
            GUILayout.Space(3);

            forceToMono = EditorGUILayout.Toggle(AssetImportStyles.Audio.ForceToMono, forceToMono);
            EditorGUI.indentLevel++;
            EditorGUI.BeginDisabledGroup(forceToMono);
            normalize = EditorGUILayout.Toggle(AssetImportStyles.Audio.Normalize, normalize);
            EditorGUI.EndDisabledGroup();
            EditorGUI.indentLevel--;
            loadInBackground = EditorGUILayout.Toggle(AssetImportStyles.Audio.LoadBackground, loadInBackground);
            ambisonic        = EditorGUILayout.Toggle(AssetImportStyles.Audio.Ambisonic, ambisonic);

            GUILayout.Space(6);
            EditorGUILayout.LabelField("Default Import Settings", EditorStyles.boldLabel);
            EditorGUI.DrawRect(EditorGUILayout.GetControlRect(false, 2), QuickEditorColors.DarkGrayX11);
            GUILayout.Space(3);

            loadType = (AudioClipLoadType)EditorGUILayout.EnumPopup(AssetImportStyles.Audio.LoadType, loadType);

            EditorGUI.BeginDisabledGroup(loadType == AudioClipLoadType.Streaming ? true : false);
            preloadAudioData = EditorGUILayout.Toggle(AssetImportStyles.Audio.PreloadAudioData, preloadAudioData);
            EditorGUI.EndDisabledGroup();

            if (loadType == AudioClipLoadType.Streaming)
            {
                preloadAudioData = false;
            }

            int compressionFormatIndex = Math.Max(Array.FindIndex(AssetImportStyles.Audio.CompressionEnumOpts, opt => opt.Equals(compressionFormat)), 0);

            compressionFormatIndex = EditorGUILayout.Popup(AssetImportStyles.Audio.CompressionFormat, compressionFormatIndex, AssetImportStyles.Audio.CompressionFormatOpts);
            compressionFormat      = AssetImportStyles.Audio.CompressionEnumOpts[compressionFormatIndex];
            EditorGUI.BeginDisabledGroup(compressionFormat != AudioCompressionFormat.Vorbis ? true : false);
            quality = EditorGUILayout.IntSlider(AssetImportStyles.Audio.Quality, quality, 1, 100);
            EditorGUI.EndDisabledGroup();

            sampleRateSetting = (AudioSampleRateSetting)EditorGUILayout.EnumPopup(AssetImportStyles.Audio.SampleRateSetting, sampleRateSetting);
            if (sampleRateSetting == AudioSampleRateSetting.OverrideSampleRate)
            {
                sampleRate = (SampleRates)EditorGUILayout.EnumPopup(AssetImportStyles.Audio.SampleRate, sampleRate);
            }
        }
コード例 #11
0
ファイル: WaveProcessor.cs プロジェクト: jeason0813/Asmodat
        /// <summary>
        /// wave linear extrapolation into specified bitrate
        /// </summary>
        /// <param name="pcm"></param>
        /// <param name="rate"></param>
        /// <returns></returns>
        public static WaveStream WavExtrapolate16bit(WaveStream pcm, SampleRates rate)
        {
            int desiretrate = (int)rate;
            int surrentrate = pcm.WaveFormat.SampleRate;
            int multiplayer = (int)desiretrate / surrentrate;

            if (multiplayer <= 1)
            {
                return(pcm);
            }

            bool swap = true;

            byte[]  data      = Converter.WaveStreamToArray(pcm);
            short[] dataSha   = Converter.WavToShortArray(data, swap);
            short[] outputSha = new short[dataSha.Length * multiplayer];


            int first = 0, second = 0;
            int i = 0, h = 0;

            for (; i < dataSha.Length - 1; i++, h += multiplayer)
            {
                first  = dataSha[i];
                second = dataSha[i + 1];
                double y = second - first;
                double x = multiplayer;
                double a = (double)y / x;

                outputSha[h] = (short)first;
                for (int i2 = 1; i2 < multiplayer; i2++)
                {
                    outputSha[h + i2] = (short)((double)first + (double)(a * i2));
                }
            }

            outputSha[outputSha.Length - 1] = (short)second;

            byte[] outputdata = Converter.WavToByteArray(outputSha, swap);

            WaveFormat format       = pcm.WaveFormat;
            WaveFormat outputformat = new WaveFormat(format.SampleRate * multiplayer, format.Channels);//format.BitsPerSample,
            WaveStream outputstream = Converter.ArrayToWaveStream(outputdata, outputformat);

            return(outputstream);
        }
コード例 #12
0
            public bool Process(SampleRates inputSampleRate, float[] input, float[] output)
            {
                using (var handle = _handle.Lock())
                {
                    if (handle.Value == IntPtr.Zero)
                    {
                        throw Log.CreatePossibleBugException("Attempted  to access a null WebRtc Preprocessor encoder", "5C97EF6A-353B-4B96-871F-1073746B5708");
                    }

                    var result = Dissonance_PreprocessCaptureFrame(handle.Value, (int)inputSampleRate, input, output);
                    if (result != ProcessorErrors.Ok)
                    {
                        throw Log.CreatePossibleBugException(string.Format("Preprocessor error: '{0}'", result), "0A89A5E7-F527-4856-BA01-5A19578C6D88");
                    }

                    return(Dissonance_GetVadSpeechState(handle.Value));
                }
            }
コード例 #13
0
ファイル: SoundBankWizard.cs プロジェクト: gregzo/G-Audio
    void OnGUI()
    {
        EditorGUIUtility.fieldWidth = 60f;
        EditorGUIUtility.labelWidth = 80f;
        _sampleRate = ( SampleRates )EditorGUILayout.EnumPopup( "Sample Rate:", _sampleRate, GUILayout.ExpandWidth( false ) );

        GUILayout.Space( 10f );

        GUI.color = Color.green;
        if( GUILayout.Button( "Create", GUILayout.Width( 70f ) ) )
        {
            GATSoundBank soundBank = GATEditorUtilities.CreateAsset< GATSoundBank >("New SoundBank" );

            switch( _sampleRate )
            {
                case SampleRates._24000:
                soundBank.Init( 24000 );
                break;

                case SampleRates._44100:
                soundBank.Init( 44100 );
                break;

                case SampleRates._48000:
                soundBank.Init( 48000 );
                break;

                case SampleRates._88200:
                soundBank.Init( 88200 );
                break;

                case SampleRates._96000:
                soundBank.Init( 96000 );
                break;

            }

            this.Close();
        }
    }
コード例 #14
0
    void OnGUI()
    {
        EditorGUIUtility.fieldWidth = 60f;
        EditorGUIUtility.labelWidth = 80f;
        _sampleRate = ( SampleRates )EditorGUILayout.EnumPopup("Sample Rate:", _sampleRate, GUILayout.ExpandWidth(false));

        GUILayout.Space(10f);

        GUI.color = Color.green;
        if (GUILayout.Button("Create", GUILayout.Width(70f)))
        {
            GATSoundBank soundBank = GATEditorUtilities.CreateAsset <GATSoundBank>("New SoundBank");

            switch (_sampleRate)
            {
            case SampleRates._24000:
                soundBank.Init(24000);
                break;

            case SampleRates._44100:
                soundBank.Init(44100);
                break;

            case SampleRates._48000:
                soundBank.Init(48000);
                break;

            case SampleRates._88200:
                soundBank.Init(88200);
                break;

            case SampleRates._96000:
                soundBank.Init(96000);
                break;
            }

            this.Close();
        }
    }
コード例 #15
0
ファイル: SampleRates.cs プロジェクト: stephen4180/MSCL_Copy
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SampleRates obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #16
0
ファイル: AudioFSB5.cs プロジェクト: zxc120/GARbro
        List <Sample> ReadSamples()
        {
            var header       = m_input.ReadHeader(0x3C);
            int version      = header.ToInt32(4);
            int sample_count = header.ToInt32(8);

            m_sample_header_size = header.ToInt32(0xC);
            m_name_table_size    = header.ToInt32(0x10);
            m_data_size          = header.ToInt32(0x14);
            m_format             = (SoundFormat)header.ToInt32(0x18);
            if (!Supported.Contains(m_format))
            {
                throw new NotSupportedException();
            }

            if (0 == version)
            {
                m_input.ReadInt32();
            }
            var samples = new List <Sample> (sample_count);

            m_header_size = (int)m_input.Position;
            for (int i = 0; i < sample_count; ++i)
            {
                long   raw         = m_input.ReadInt64();
                bool   next_chunk  = 0 != (raw & 1);
                int    sample_rate = (int)((raw >> 1) & 0xF);
                ushort channels    = (ushort)(((raw >> 5) & 1) + 1);
                long   data_offset = ((raw >> 6) & 0xFFFFFFF) * 0x10;
                int    count       = (int)((raw >> 34) & 0x3FFFFFFF);
                var    chunks      = new Dictionary <ChunkType, object>();
                while (next_chunk)
                {
                    int d = m_input.ReadInt32();
                    next_chunk = 0 != (d & 1);
                    int    chunk_size = (d >> 1) & 0xFFFFFF;
                    var    chunk_type = (ChunkType)((d >> 25) & 0x7F);
                    object chunk;
                    switch (chunk_type)
                    {
                    case ChunkType.Channels:
                        chunk = m_input.ReadUInt8();
                        break;

                    case ChunkType.SampleRate:
                        chunk = m_input.ReadInt32();
                        break;

                    case ChunkType.Loop:
                        int v1 = m_input.ReadInt32();
                        int v2 = m_input.ReadInt32();
                        chunk = Tuple.Create(v1, v2);
                        break;

                    case ChunkType.VorbisData:
                        chunk = new VorbisData {
                            Crc32 = m_input.ReadUInt32(),
                            Data  = m_input.ReadBytes(chunk_size - 4) // XXX unused
                        };
                        break;

                    default:
                        chunk = m_input.ReadBytes(chunk_size);
                        break;
                    }
                    chunks[chunk_type] = chunk;
                }
                if (chunks.ContainsKey(ChunkType.SampleRate))
                {
                    sample_rate = (int)chunks[ChunkType.SampleRate];
                }
                else if (SampleRates.ContainsKey(sample_rate))
                {
                    sample_rate = SampleRates[sample_rate];
                }
                else
                {
                    throw new InvalidFormatException("Invalid FSB5 sample rate.");
                }

                var sample = new Sample {
                    SampleRate  = sample_rate,
                    Channels    = channels,
                    DataOffset  = data_offset,
                    SampleCount = count,
                    MetaData    = chunks,
                    Data        = null
                };
                samples.Add(sample);
            }
            return(samples);
        }
コード例 #17
0
 public void Reset()
 {
     FffWindowType = FFTWindow.BlackmanHarris;
     sampleRate = SampleRates.Hz2048;
 }
コード例 #18
0
 public void Reset()
 {
     FffWindowType = FFTWindow.BlackmanHarris;
     sampleRate    = SampleRates.Hz2048;
 }