[Java] Make a musical note without using any external library

  • Java
  • Thread starter Silicon Waffle
  • Start date
  • Tags
    Java
In summary, the conversation discusses how to make a musical note in Java without using any external libraries. The basic answer is using "java.awt.Toolkit.getDefaultToolkit().beep();" while more specialized code is needed for frequency and duration. The conversation also mentions using C# and a real-time vocoder in Java. Additionally, the conversation touches on the western temperment and the use of beep codes in PCs during boot.
  • #1
Silicon Waffle
160
203
:oldsmile:Do you know how to make a musical note in Java without using any external library ?
In C# I can simply do this :
PHP:
Console.Beep(50,1000); //play a sound at 50Herz of frequency within 1 second
 
Technology news on Phys.org
  • #3
...

5 years of c# coding and I had no idea Console.Beep existed. Mind == Blown
Have actually wanted sound synthesizing code for awhile without using a library, thank you.
 
Last edited:
  • #4
Isn't the system beep something special though? I seem to remember a desktop computer where system beep came from a special speaker, other than the speakers.

I programmed a real-time vocoder in Java once, it wasn't the best language for real time audio, but it did work. I'm pretty sure I just used the builtin:
https://docs.oracle.com/javase/tutorial/sound/
If you're actually wanting to make the musical notes, the western temperment is called 12TET, you'll find the math here:
https://en.wikipedia.org/wiki/Equal_temperament#Twelve-tone_equal_temperament
 
  • #5
Superposed_Cat said:
Mind == Blown

Isn't that a comparison, and not an assignment?
 
  • #7
berkeman said:
Isn't that a comparison, and not an assignment?
I,m stating equality,I'm not assigning mind to blown.
 
  • Like
Likes berkeman

Related to [Java] Make a musical note without using any external library

1. How can I make a musical note in Java without using any external library?

To make a musical note in Java without using any external library, you can use the built-in javax.sound.midi package. This package allows you to generate MIDI (Musical Instrument Digital Interface) sounds, which can be used to create musical notes.

2. Can I create different types of musical notes using this method?

Yes, you can create different types of musical notes using the javax.sound.midi package. This package provides methods for creating notes of different durations, pitches, and instrument sounds.

3. Do I need any prior knowledge of music or MIDI to make a musical note in Java?

While having prior knowledge of music or MIDI can be helpful, it is not necessary to create a musical note in Java using the javax.sound.midi package. You can simply follow the documentation and examples provided by Oracle to generate the desired musical note.

4. Can I use this method to create multiple musical notes at the same time?

Yes, you can use this method to create multiple musical notes at the same time. The javax.sound.midi package allows you to create and play multiple notes simultaneously by utilizing the Sequencer class.

5. Are there any limitations to making musical notes in Java without external libraries?

The limitations to making musical notes in Java without external libraries depend on the capabilities of the javax.sound.midi package. While it allows you to create and play basic musical notes, it may not have the advanced features and sounds provided by external libraries specifically designed for creating music.

Similar threads

  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
1
Views
999
  • Programming and Computer Science
Replies
10
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
15
Views
5K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
14
Views
3K
Back
Top