I know this is very well possible and easy but I am not sure where to start! I have seen someone take MIDI file and play it on the peizo. Now, forget MIDI file…how do i make some cool noises like the old Atari did? IT should be just a sequence of frequencies that you have to feed in to the PWM but what frequencies? Is there some project that I can copy those sequences from?
The support guy is asking fro support! It is your chance to help back
no because I do not want to play songs, I would just use MIDI for that. I want to generate cool noises, like the ones you hear in old arcade games. Like how do you make an explosion sound from a peizo? or a whistle?
Ah… I think most of the early games had multi-channel sound chips. I think you might be able to generate sounds with hugh OutputCompare arrays…
There are a lot of sites on the web that have audio clips for various Atari sounds. I think the easiest way would be to find mp3 sound clips and use the mp3 extension.
Maybe use a raw 32Khz .WAV file to get the PCM code and then feed the PWM with that. You may need a small amplifier eg. LM3xx and a 2nd order filter if the 8Khz buzz is present.
Thanks Raj, this is what I usually do. I actually have this already on the LED arcade we made. I was trying to see if there is something that would make better sounds.
I will still try your sequences. It maybe sound cooler than what I have:)
You could use these frequencies to produce some musical notes. However since the parameter to the Utility.Piezo method is unit we have to truncate the decimal part.
How fast can the Analog Output ports be set? If you modulate the PWM with the Analog Output via a NPN transistor you might be able to do AM and FM modulation and get explosions.
So I managed to hook up one of the PWM to the Collector input of an NPN transistor, the base to the analog output, and a speaker to the emitter. The speaker then connects to ground. Using the following code I managed to get some “explosion” like sounds from the AMThread. The FMThread produces weird computer sounds.
using System;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
namespace Fez_Music
{
public class Program
{
public static void Main()
{
Thread _amThread = new Thread(AMThread);
Thread _fmThread = new Thread(FMThread);
//_fmThread.Start();
_amThread.Start();
Thread.Sleep(Timeout.Infinite);
}
private static void FMThread()
{
PWM _fmPort = new PWM(PWM.Pin.PWM5);
uint _nanoSecond = 1000000000;
int _frequency = 0; //in hertz
float _hertz = 0;
Random _random = new Random();
while (true)
{
_frequency = _random.Next(200) + 1000;
_hertz = (float)1 / (float)_frequency;
_fmPort.SetPulse((uint)(_hertz * _nanoSecond), (uint)((_hertz / 2) * _nanoSecond));
Thread.Sleep(_random.Next(100) + 100);
}
}
private static void AMThread()
{
AnalogOut _amPort = new AnalogOut((AnalogOut.Pin)FEZ_Pin.AnalogOut.A3);
_amPort.SetLinearScale(0, 3301);
Random _random = new Random();
while (true)
{
_amPort.Set(_random.Next(2000) + 1000);
Thread.Sleep(1);
}
}
}
}