Ejemplo n.º 1
0
        public void DoBeatBarDetection(ICollection <IMarkCollection> markCollection)
        {
            if (m_audioModule.Channels != 0)
            {
                m_plugin = new QMBarBeatTrack(m_audioModule.Frequency);

                m_bSamples        = m_audioModule.GetSamples(0, (int)m_audioModule.NumberSamples);
                m_fSamplesAll     = new float[m_audioModule.NumberSamples];
                m_fSamplesPreview = new float[(int)(m_audioModule.Frequency * PREVIEW_TIME)];

                int dataStep = m_audioModule.BytesPerSample;

                for (int j = 0, sampleNum = 0; j < m_bSamples.Length; j += dataStep, sampleNum++)
                {
                    m_fSamplesAll[sampleNum] = dataStep == 2 ?
                                               BitConverter.ToInt16(m_bSamples, j) : BitConverter.ToInt32(m_bSamples, j);
                }

                Array.Copy(m_fSamplesAll,
                           m_fSamplesPreview,
                           (int)Math.Min((m_audioModule.Frequency * PREVIEW_TIME), m_fSamplesAll.Length));

                BeatsAndBarsDialog bbSettings = new BeatsAndBarsDialog(m_audioModule);
                bbSettings.PreviewData        = GeneratePreviewData();
                bbSettings.MarkCollectionList = markCollection.ToList();

                DialogResult result = bbSettings.ShowDialog();
                if (result == DialogResult.OK)
                {
                    m_plugin.SetParameter("bpb", bbSettings.Settings.BeatsPerBar);

                    m_plugin.Initialise(1,
                                        (uint)m_plugin.GetPreferredStepSize(),
                                        (uint)m_plugin.GetPreferredBlockSize());

                    BuildMarkCollections(markCollection, bbSettings.Settings);
                }
            }

            if (markCollection.Any() && !markCollection.Any(x => x.IsDefault))
            {
                markCollection.First().IsDefault = true;
            }
        }
Ejemplo n.º 2
0
		public List<MarkCollection> DoBeatBarDetection(List<MarkCollection> markCollection)
		{
			List<MarkCollection> retVal = markCollection;

			if (m_audioModule.Channels != 0)
			{
				m_plugin = new QMBarBeatTrack(m_audioModule.Frequency);

				m_bSamples = m_audioModule.GetSamples(0, (int)m_audioModule.NumberSamples);
				m_fSamplesAll = new float[m_audioModule.NumberSamples];
				m_fSamplesPreview = new float[(int)(m_audioModule.Frequency * PREVIEW_TIME)];

				int dataStep = m_audioModule.BytesPerSample;

				for (int j = 0, sampleNum = 0; j < m_bSamples.Length; j += dataStep, sampleNum++)
				{
					m_fSamplesAll[sampleNum] = dataStep == 2 ?
						BitConverter.ToInt16(m_bSamples, j) : BitConverter.ToInt32(m_bSamples, j);
				}

				Array.Copy(m_fSamplesAll,
							m_fSamplesPreview,
							(int)Math.Min((m_audioModule.Frequency * PREVIEW_TIME), m_fSamplesAll.Length));

				BeatsAndBarsDialog bbSettings = new BeatsAndBarsDialog(m_audioModule);
				bbSettings.PreviewData = GeneratePreviewData();
				bbSettings.MarkCollectionList = markCollection;

				DialogResult result = bbSettings.ShowDialog();
				if (result == DialogResult.OK)
				{
					m_plugin.SetParameter("bpb", bbSettings.Settings.BeatsPerBar);

					m_plugin.Initialise(1,
						(uint)m_plugin.GetPreferredStepSize(),
						(uint)m_plugin.GetPreferredBlockSize());

					retVal = BuildMarkCollections(markCollection, bbSettings.Settings);
				}				
			}

			return retVal;
		}