Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:26:13+00:00 2026-05-31T01:26:13+00:00

Whole day I was looking for some tutorial or piece of code, just to

  • 0

Whole day I was looking for some tutorial or piece of code, “just” to play simple sin wave for “infinity” time. I know it sounds a little crazy.

But I want to be able to change frequency of tone in time, for instance – increase it.
Imagine that I want to play tone A, and increase it to C in “+5” frequency steps each 3ms (it’s really just example), don’t want to have free places, stop the tone.

Is it possible? Or can you help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:26:14+00:00Added an answer on May 31, 2026 at 1:26 am

    Use NAudio library for audio output.

    Make notes wave provider:

    class NotesWaveProvider : WaveProvider32
    {
        public NotesWaveProvider(Queue<Note> notes)
        {
            this.Notes = notes;
        }
        public readonly Queue<Note> Notes;
        int sample = 0;
    
        Note NextNote()
        {
            for (; ; )
            {
                if (Notes.Count == 0)
                    return null;
                var note = Notes.Peek();
                if (sample < note.Duration.TotalSeconds * WaveFormat.SampleRate)
                    return note;
    
                Notes.Dequeue();
                sample = 0;
            }
    
        }
        public override int Read(float[] buffer, int offset, int sampleCount)
        {
            int sampleRate = WaveFormat.SampleRate;
            for (int n = 0; n < sampleCount; n++)
            {
                var note = NextNote();
                if (note == null)
                    buffer[n + offset] = 0;
                else
                    buffer[n + offset] = (float)(note.Amplitude * Math.Sin((2 * Math.PI * sample * note.Frequency) / sampleRate));
                sample++;
            }
            return sampleCount;
        }
    }
    class Note
    {
        public float Frequency;
        public float Amplitude = 1.0f;
        public TimeSpan Duration = TimeSpan.FromMilliseconds(50);
    
    }
    

    start play:

    WaveOut waveOut;
    this.Notes = new Queue<Note>(new[] { new Note { Frequency = 1000 }, new Note { Frequency = 1100 } });
    var waveProvider = new NotesWaveProvider(Notes);
    waveProvider.SetWaveFormat(16000, 1); // 16kHz mono    
    
    waveOut = new WaveOut();
    waveOut.Init(waveProvider);
    waveOut.Play();
    

    add new notes:

    void Timer_Tick(...)
    {
     if (Notes.Count < 10)
       Notes.Add(new Note{Frecuency = 900});
    }
    

    ps this code is idea only. for real using add mt-locking etc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A friend of mine asked me the other day if I'm just looking at
intro : I spent whole day looking why my processing operation is so so
I've been looking around the web for a whole day, but didn't found a
I spent a whole day looking for a bug caused by wrongly passing Windows
I've spent a whole day on this already without figuring it out. I'm hoping
I have spent the whole day trying to make a script which on submit
OKay I lost alsmost the whole day on this. I have a webapp where
While looking for something totally different the other day, I have stumbled upon two
I have been for a long time looking into .. what is the best
I'm looking for some advice for a table structure in sql. Basically I will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.