generating 500hz tone at 1000 hz sample rate doesn't work

@Doug, I changed your link to point to the equivalent article in the current Manual, rather than the obsolete 1.2 Manual. Thanks!

Gale

The Square Wave choice in Generate > Tone works at half the sample rate in terms of being audible, though the waveform looks untypical of a square wave.


Gale

and “Square (no alias)” produces silence.
To see why, look at the starting point of the waveform when generating a tone well below the Nyquist frequency. The starting point will be the first dot, then there will be dots for each consecutive 1/2 cycle.

It’s the same as a cosine wave–the zero crossings are mid-point between samples thus you do not have the zeros from the sine wave.
By the way, shouldn’t we have a little bit more than the current wave-forms?
For example:

  • Saw-tooth, no alias
  • Triangle (+ no alias)
  • Buzz (summation of cosines up to Nyquist, gives single impulses at <=1 Hz)
    optionally:
  • square waves with other duty factors, not only 50 %.
  • sine bursts

OK, I made a note of that.


Gale

There is a plug-in here that offers a wider range of waveforms: New plug-in: Tone Generator
and one here with a range of “no alias” waveforms: High Quality (no alias) Tone generator

Perhaps these should be combined into one plug-in and uploaded to the wiki?

+1 if you can. I find it too hard to locate plug-ins in New Plug-Ins - Audacity Forum and often a search will produce several similar plug-ins that are the same as each other except for one or two different controls.


Gale

I still think that the changes should go directly into audacity’s shipped effect.
It makes no sense to have a alias-free square wave but no alternative to saw-tooth.

Perhaps we should ship the Nyquist tone generator instead of the current built in Tone generator.
For the non-alias versions, the Nyquist effect is much faster than the built-in effect, particularly for low frequency waveforms, and we could have a Preview button if we wished to.

Sure, why not.
Should we have a “Allow Aliasing” control instead of doubling the wave-forms?

That makes sense.

Do you think that it is worth having a Preview button on a simple waveform generator? I’m thinking perhaps not as it is not an effect that users are going to be able to “tweak”, though it may be instructive if users can quickly hear the tone difference between allowing or not allowing aliasing.

“Instructive” is the keyword here. It might be helpful for total novices to experiment without reenter the tone generator again and again.
Also, amplitude and frequency are tweaked too, thus it is nice to set them on the fly.

Last but not least, the plug-in can display warnings as well, if the frequency is for instance >= Nyquist. The user has therefore a second chance to enter proper values when he’s tried the preview first.

I can think of 2 reasons why not:

  1. For waveforms where aliasing is allowed, the built-in effect is quicker than the Nyquist effect.
  2. The built-in effect has a time control widget for entering the duration (hh:mm:ss)

but also several reasons why the Nyquist version would be preferable:

  1. MUCH faster generating low frequency alias free tones.
  2. Can have a preview button.
  3. Can easily be extended for additional waveforms.
  4. Very easily maintained.
  5. Adjustable starting phase.
  6. Supports very low frequencies (< 1 Hz).
  7. Supports frequencies up to (and including) the Nyquist frequency.

Well, a 1 hour square wave (with your hq tone plug-in) in 6 seconds is for me fast enough.
The tones will most likely not be longer than a few seconds in average.
They are very boring when listening to them over a longer time–and the dogs get crazy as well. :smiley:

Omitting the time input spin box is a pity, I admit, especially for special formats and for the fact that the selected time is automatically passed on.
We should keep that in mind for version 4 plug-ins.

  1. is a significant disbenefit.

Didn’t we previously use the Nyquist DTMF Generator then made a built-in effect?

So are those apart from 3) and 4) bugs or limitations in the built-in generator? What does 7) mean? Tone Generator doesn’t generate a 22050 Hz Sine tone at 44100 Hz sample rate.

We could fix those problems, e.g. allow Preview in built-in Generate effects?

There is no huge demand for new tones - most of the requests want Triangle added. I see no harm in shipping an advanced Tone Generator as well as the built-in one, if the Nyquist one has sufficient features. The custom oscillation looks interesting. I can’t see the need for the amplitude scale control. The “Square, no alias” could be removed from the built-in generator if we had a Nyquist generator too.

Any other cool features you could add that would (possibly) justify a separate Nyquist Generator? Some sort of control for extra/reduced overtones?

One guy recently requested generating antimatter tones: http://www.youtube.com/watch?v=tEZqTnlFe3Y. Should that be an effect, rather than part of the generation?


Gale

There’s no reason why Nyquist plug-ins can’t have time control widgets, other than that no-one has written that into the Audacity/Nyquist interface yet.
Roll-on “version 4” :wink:

I think you’re right, but with the current emphasis on maintaining a stable core application and moving other things into modules/plug-ins, that may not have been the best thing to do (in retrospect). The limitations in Nyquist plug-ins have little to do with Nyquist, but are (mostly) limitations of the under-developed interface between Nyquist and Audacity.

All 7 are “limitation” of the built-in generator (I’d not call them bugs).
Overcoming those limitations is (probably) possible, though with varying difficulty. Number 6 (Supports very low frequencies) would be very difficult (impossible?) to achieve with the current code.

All of those limitations are very easy to overcome in a Nyquist effect.

I’d say “there is little visible demand”.

There is also little “visible” demand for MIDI editing. About the only MIdI features we ever get asked for are recording and playback. That’s because people that know what MIDI is, also know that Audacity “does not do MIDI editing”. Similarly, people that know about sound synthesis “know” that Audacity is pretty rubbish at sound synthesis, which is a great shame because Audacity has Nyquist built in and Nyquist is awesomely powerful for sound synthesis.

Do you mean the choice of dB / linear?

I agree.

There’s a lot that “could” be added, but as always we are running into limitations of the current interface. That is the main thing that has deterred me from publishing generator/synthesizer plug-ins. An improved Audacity/Nyquist interface and access for Nyquist to MIDI tracks would be a game changer.

Cool sounding name :smiley:
What’s it mean???
It seems to be a kind of modulation effect where the modulation frequency is tied to the main generator frequency. I’m not sure that I could reproduce that exactly without knowing the algorithm (which would probably breach copyright), but that type of synthesis effect could easily be done as a generator.


It’s firmly on the agenda.

If the Nyquist Advanced Generator does more than generate a single tone (so that e.g. it could create simple sequences), I would see more point to it. Though a fully featured Nyquist sequencer would be good too.

And yes there is some demand for “sequencers”.

Yes, that control is called “Amplitude Scale” in the version I have.

So what was the problem with the built-in Generator in “7) Supports frequencies up to (and including) the Nyquist frequency”?


Gale

There are already people that use Audacity for editing instrument samples for use in samplers and sequencers. For example, there are a lot of references on the Internet to using Audacity as an external editor for Ableton Live.

https://forum.ableton.com/viewtopic.php?p=967170#p967170
http://ableton-live.tribe.net/thread/e6c8539d-a1fa-428c-818a-752eb9f2c7e8#b61c76ac-d743-4387-a1f0-adee17b1b4a2

In some cases the original audio sample will come from a recording (which may be done in Audacity)
Sometimes it may be copied from somewhere, which may be done with Audacity,
or it may be generated by a synthesizer, which could in the future also be Audacity.

Well it can, but as you can probably guess, the Audacity / Nyquist interface lets it down.

Here is a simple example plug-in.
Karplus-Strong.ny (1.48 KB)
The “music” is not particularly inspiring :wink: but it illustrates a couple of interesting features.

Firstly, the sound is an implementation of “Karplus-Strong string synthesis” (Karplus–Strong string synthesis - Wikipedia). It is a simple example of “physical modelling synthesis” (all the rage in the late '90’s) that produces plucked/struck string type sounds. This is just one of many types of synthesis that Nyquist can do (others include additive, subtractive, granular, FM, and virtually any other).

The other is that it is a simple monophonic sequencer (it can play “tunes”). A melody line, prepared in any text editor, can be pasted into the plug-in.
In this example, the melody is:

d3 g3 a3 b3 c4 d4 e4 d4 b3 c4 d4 e4 fs4 g4 a4 g4 e4 d4 e4 d4 b3 c4 b3 a3 g3 fs3 g3 a3 g3 fs3 d3 e3 fs3 g3 a3 b3 c4 d4 e4 d4 b3 c4 d4 e4 fs4 g4 fs4 g4 a4 b4 a4 g4 fs4 g4 fs4 e4 d4 cs4 d4 e4 fs4

(If you have a piano I expect that you can work out how to play that melody)

It would be much nicer if the melody could be read from a MIDI files, or better still, read from an Audacity MIDI track!

That’s not essential. It’s only there because I prefer to work in dB and the tradition in Audacity is for linear scale.
I presume that you would prefer linear scale.

Nice to get back to the original question
It’s as DVDdoug described (generating 500hz tone at 1000 hz sample rate doesn't work - #6 by DVDdoug).
The sine wave oscillator always starts at 0 degrees (the waveform rising from zero), as do the other oscillators except for “Square No Alias”.
Simple waveforms like these cross the zero line every 1/2 cycle.
If the frequency of the waveform is exactly the Nyquist frequency (half the sample rate), then the waveform will be crossing the zero line at each and every sample position. All of the samples will be exactly = 0.0 which is another way of saying “silence”.

In order to produce a non-silent waveform at the Nyquist frequency, the starting phase must be non-zero (as demonstrated by the code examples that I posted here: generating 500hz tone at 1000 hz sample rate doesn't work - #4 by steve

That being the case, we should make it easier for them by exporting to where the temp file comes from. :wink:

Yes I think it should be whichever waveform scale is default, which is currently linear.

You mean, except “Square”, I assume?

OK, then it was only the same question we started with.

So in the Tone Generator I did not find a phase control. Should there be such? I had to guess which type of waveform did not start at phase 0.


Gale

+1
I recall that this was discussed several years ago in relation to Ardour (DAW). If I recall correctly, one of the Ardour developers was involved in the conversation and very much in favour.

Despite this difficulty, Audacity is still quite popular as an “external editor” for DAW applications. By far the most common criticism of Audacity for this type of use is that Audacity does not make it easy to export the file back to where it came from.

Unfortunately there is a downside to making this easier, which is that it would encourage users to overwrite their “source” files, which (although much safer these days than previously), carries quite severe risks. I’m certainly not saying that we shouldn’t do it (I’m strongly in favour), just that we would need to give careful thought about how to mitigate the risks.


No problem.


Yes, whichever one it is :smiley:


The “HQ-Tone” generator has a “Phase” control.
If the user is bothered about aliasing, then they may well be bothered about phase.

The other “Tone Generator…” leaves out the phase control so as to save space in the interface.

Geek alert for the next section :ugeek:

For sine waves, there is a well established convention that “0 degrees phase” starts with the waveform rising from zero. This is obvious and undisputed (try “sin 0” on a calculator). For other waveforms, the position of “0 degrees” is less defined. More often than not, the zero phase point of a square wave is taken as the start of the positive part of the waveform.

A “pure” square wave is unrealizeable either in the analog or digital domains. It is a “theoretical concept” (like an infinitely small dot or infinitely thin line). Digitally, the maximum slope rises from -1 to +1 in one sample period, whereas in a “pure” (theoretical) square wave, the rise slope is infinite (vertical). This puts the 0 degrees phase point for a “pure” square at the start of the positive part of the waveform, and for a digital square wave, half way between that point and the last sample of the negative portion.

An alias free square wave can be defined in terms of the addition of multiple sine waves up to the Nyquist frequency, In this case, because all of the sine components are in phase, the phase of an alias free square wave is usually defined as the same as the sine wave components.

The starting point (0 degrees phase) for “sawtooth” and “inverse saw” waves is debatable. The two waveforms are expected to be the inverse of each other, so one of them must be “wrong”. By convention, the 0 degree phase point for a sawtooth waveform is usually taken as either: the point at which the waveform rises from zero, or the point at which the waveform rises from the most negative point.

For complex waveforms, the 0 degrees phase point becomes largely arbitrary because different sine components are likely to not be in phase with each other.