Home | Java |     Share This Page

A Java-based signal generator

P. Lutus Message Page

Copyright © 2011, P. Lutus

Current Version: 1.4 (08/11/2012)

Discussion | Licensing, Source | Revision History

(double-click any word to see its definition)

Note: Because this generator relies on a Java applet, and because Java applets are no longer trusted, I have written yet another Web-based signal generator to replace it. Follow this link to see the new version.

JSigGen running as an applet
(click "Enable" to start the generator)

This is the latest incarnation in a rather long series of programs — it is meant to replace an older program, which in turn replaced an even older program that, because of gradual changes in Linux and in various program development environments, is about to stop working entirely.

This new program has a number of adantages over its predecessors — unlike them it is portable between platforms because it runs under Java. It has a number of improvements in code and interface. It results from the fact that I have an amost daily need for such a signal generator, which means I have been gradually improving it.

This program uses your system's sound card as an output device, so the program's bandwidth is roughly the same as your sound card. The program creates various kinds of waveforms — sine, triangle, square and sawtooth — and in a wide range of frequencies. It can be used to troubleshoot computer sound system issues or test the abilities of your multimedia system. It can even be used to tune musical instruments — its frequency accuracy is much better than a traditional standard like a tuning fork.

This program belongs to a relatively new class of programs that represent virtual equivalents of classic test instruments — signal generators, oscilloscopes and other kinds of equipment are gradually disappearing, replaced by computer programs and various kinds of hardware interfaces to connect to the real world.

In this case, the only real range limit is posed by the system sound card, which can be relied on to create signals up to about 1/2 the selected sampling rate (on the basis of the Nyquist–Shannon sampling theorem). While using this program, my system's sound card can support a maximum sampling rate of 192,000 samples per second, so on that basis I am able to generate usable signals between 0 Hz - 96 KHz.

This is one of the reasons I rewrote this program in Java. This program's immediate predecessor (SignalGen) was written in Python, but because Python is interpreted, it can't deliver data fast enough to support high data rates. Unlike its predecessor, this new program handily generates data at the highest available rates.

State Recall

As with most of my recent programs, when JSigGen is running as an application, it remembers all your settings between uses. It saves its state in an initialization file located at (user home directory)/.JSigGen.ini.

As an applet, as on this page, for security reasons it cannot save or recall settings.

Mouse Wheel Function

You can type numbers for the frequency and level program entries, but if you prefer, you can also place your mouse cursor over the desired entry window and spin your mouse wheel to change the numerical value. If the default rate of change is not fast enough, press Ctrl, Alt or Shift while spinning the mouse wheel — each of these modifier keys multiplies the rate by ten times, and their effect is cumulative. (Each of Ctrl, Alt and Shift multiplies by ten, so all of them at once multiplies the rate of change by 1,000.) Try this feature in the applet above.

Frequency Step

JSigGen users have asked for a variety of minimum frequency steps (the default is 1 Hz), but with wildly different requirements. So in JSigGen version 1.4, a command-line option has been added to choose a specific minimum frequency step. To use this feature, launch JSigGen this way:

java -jar JSigGen.jar --fstep=xxxx

Replace "xxxx" with the minimum frequency step you want (e.g. 0.01, 0.1, 10, 100). Remember that, as explained above, you can multiply the frequency step size by pressing any combination of Ctrl, Alt and Shift while spinning the mouse wheel.


Building on this program's predecessors, I have added modulation and noise sources to the feature set. The modulation capability is especially useful, and was added in support of another project that needed various kinds of modulated waveforms for development work.

In AM modulation mode, a level of 100% simply means 100% modulation:

But in FM mode, there is no widely accepted meaning for "100% modulation". I have adopted the convention that 100% FM modulation means excursions between 0 Hz and twice the carrier frequency — for a carrier frequency of 1000 Hz, 100% modulation means swings between zero Hz and 2,000 Hz. Here is an example of 50% FM modulation:

For those curious about the mathematics, here are equations for the AM and FM modulation schemes:

$ \displaystyle am(t) = \cos(2 \pi f_c t) \left(\frac{1 + a_m\ \cos(2 \pi f_m t)}{2}\right)$

$ \displaystyle fm(t) = \cos \left(2 \pi f_c \left(t + a_m \int \cos(2 \pi f_m t)\ dt\right) \right) $

  • t = time, seconds
  • fc = carrier frequency, Hz
  • fm = modulation frequency, Hz
  • am = modulation amplitude, 0 <= am <= 1

As shown, the equations assume sinusoidal carrier and modulation waveforms, but in this program all the waveform types (sine, triangle, square and sawtooth) are available for both carrier and modulation.

Modulation Index

Those who are accustomed to thinking of FM modulation in terms of "modulation index", that is, a maximum frequency deviation from a carrier frequency, may use this equation:

$ \displaystyle mi = 100 \frac{f_{d}}{f_c}$

  • mi = modulation index "level" value for JSigGen
  • fd = maximum desired frequency deviation
  • fc = carrier frequency

Licensing, Source

Revision History


Home | Java |     Share This Page