EvilZone
Programming and Scripting => Projects and Discussion => : L0rd_M@dness July 23, 2013, 02:52:51 AM
-
Yup; I wanna code music! xD
I did some research on this, so to start with:
Codes a MIDI creator, and writes music to MIDI file using C++: http://www.youtube.com/watch?v=6PFf6klllAE (http://www.youtube.com/watch?v=6PFf6klllAE)
OpenAL, obviously: [size=78%]http://connect.creativelabs.com/openal/default.aspx (http://connect.creativelabs.com/openal/default.aspx)[/size]
A simple beep in C++: [size=78%]http://stackoverflow.com/questions/4060601/make-sounds-beep-with-c (http://stackoverflow.com/questions/4060601/make-sounds-beep-with-c)[/size]
Also using the Beep() function from windows.h
However, none of those were what I was looking for. To start with, I want to make the computer beep using the piezo buzzer (I'm actually not sure if computers use piezo buzzers to beep when speakers are not available), and make beep music using various frequencies & durations. Then move on to more advanced stuff.
I appreciate any of evilzoners' help in introducing me to some resources. :)
Oh, and I preferably want to stay away from libs (and trackers are out of context) to begin with... just for the sake of learning.
-
You better learn java then as it will give you a good start for audio programming. Also creating music programmatically sounds a bit odd and should be said as Audio programming. The thread title is misleading.
-
Changed title.I know java, but I don't see how Java specifically is suitable for audio programming. Can you elaborate a bit on that?
-
I think I know what you're talking about... you cannot make the computer beep if it does not have a microphone for audio signals. And only desktops would have it.
To make the computer beep, try Pascal. I have been coding in pascal for few years and used this for audio signals: http://www.freepascal.org/docs-html/rtl/crt/sound.html
Ask here if you'll need help :)
-
I think I know what you're talking about... you cannot make the computer beep if it does not have a microphone for audio signals. And only desktops would have it.
To make the computer beep, try Pascal. I have been coding in pascal for few years and used this for audio signals: http://www.freepascal.org/docs-html/rtl/crt/sound.html (http://www.freepascal.org/docs-html/rtl/crt/sound.html)
Ask here if you'll need help :)
I assume by 'Microphone' you mean 'Speaker' am i right?
It's surprising how few articles are available about this (or I just can't google right :P )
After some more research (http://computer.howstuffworks.com/sound-card.htm)I found out that there's no piezo buzzer, it's a basic internal speaker that works independent from the sound card (which is probably what you meant). What I don't get is: 1. How would it function without a soundcard? 2. How to access it instead of external speakers? 3. How come it only beeps?
Oh, the doc says "On Windows the frequency is ignored :(" means no music! :( Just sound
-
Lol sorry, yes I meant the speaker.
The speaker is independant because it is build that way. For sound card you need drivers and the pc speaker is controlled directly from the mobo. Thats why it is used for audio signals such as error beeps and whatnot on mobo system check.
The speaker can emit any kind of sound. Its kike saying that a piano can only make a note... Pascal and probably other langs can make the beep at different freqsand when they are timed you get some sort of music...
I will post more when I get home in the evening :P
-
Well, I made some sort of sound (can't call it music yet), but it's more like someone dialing a number on a digital home phone with a rhythm. :P
Here's the code if anyone is interested (It's better if you're not) (You've been warned, the sound is Not pleasant!)
#include <windows.h>
int main()
{
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Sleep(200);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Sleep(200);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(800,150);
Beep(800,150);
Beep(900,150);
Beep(600,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(800,150);
Beep(800,150);
Beep(900,150);
Beep(600,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Sleep(200);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Sleep(200);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(800,150);
Beep(800,150);
Beep(900,150);
Beep(600,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(600,150);
Beep(600,150);
Beep(700,150);
Beep(800,150);
Beep(800,150);
Beep(900,150);
Beep(600,150);
return 0;
}
This C++ code will compile on windows only, but the pascal version of the same code will compile on everything except windows :P For linux, gcc I believe has beep() and sleep()...
Now what I don't understand is the delay between each beep. It's really annoying.
Also the Beep sound will just be played through regular speakers in a laptop. On desktops, it'll probably be played through the internal pc speakers, but I haven't tested.
-
Make it beep dubstep!
-
Changed title.I know java, but I don't see how Java specifically is suitable for audio programming. Can you elaborate a bit on that?
I am talking about this :- http://www.jsresources.org/faq_audio.html#dataline_notification
http://docs.oracle.com/javase/1.4.2/docs/guide/sound/programmer_guide/contents.html
-
Pascal does indeed compile on Windows, and FPC is a cross-platform compiler.
Here you can try this code I wrote some time back, it should work if your desktop has a hardware speaker in the box:
program speaker;
uses Crt;
var note : integer;
begin
note := 1;
while note <> 500 do
begin
writeLn('Groju ',note,' tona');
sound(note);
delay(100);
noSound;
note := note + 1;
end;
readLn;
end.
Or download the compiled version: http://upload.evilzone.org/download.php?id=7614772&type=zip
There was also a link posted on evilzone that I can't find. It was a tool to generate glitchy music by typing in commands.
-
It does compile on windows, but instead of generating a hardware beep, "a system sound is played and the frequency parameter is ignored".
I have a laptop which probably does not have a hardware speaker at all, so probably that's the reason.
C++ Beep() though, does still produce a BEEP sound instead of a system sound, like the pascal program and cout << "\a"; do, but it's not the most pleasant beep sound (not at least as good as the one I remember from my PC).
In any case, I think I've had my dose of experimenting with the beep. Learning about MIDI (http://www.youtube.com/watch?v=6PFf6klllAE)right now.
[/size][/font]Make it beep dubstep![/font]
Is this you: http://www.dj-rapture.com/ (http://www.dj-rapture.com/)
-
http://jugad2.blogspot.nl/2013/04/pysynth-pure-python-music-synthesizer.html
No exactly scratch but its lower level and better than beeps.
Check out its source code and you just might learn something.
-
This is all crap. Forests Mims can help you a lot here. You need to know how amplifiers work along with some PWM. Grab a few 555 timers and learn from the source.
-
Is this you: http://www.dj-rapture.com/ (http://www.dj-rapture.com/)
No, I am the US "Rapture" It was DJ Rapture but I stopped dj'ing so now it's just Rapture. www.youtube.com/djrapturemusic
-
This is all crap. Forests Mims can help you a lot here. You need to know how amplifiers work along with some PWM. Grab a few 555 timers and learn from the source.
I've made chiptune with piezo buzzer & arduino before, so I wanted to repeat the same experience on a computer then move on to more advanced stuff (amplifiers etc).
Which I kinda did... even though the sound was horrible and not as good as the piezo buzzer at all (maybe if I run it on a pc rather than a laptop I'll get a better noise since they have the hardware speakers)
I'm learning about MIDI right now, not sure if it's the perfect 2nd step, but whatev.