Static burst sound effect

in my project i need to have a short static burst follow my speech through a small amplified speaker

any idea how to accomplish this with arduino+mini amp+microphone+mp3 player?

If you can connect an SD Card reader up then you could use the SimpleSDAudio library to play sounds straight from a PWM pin(s).

You can have 8 bit Mono (1 pin), 8 bit stero (2 Pins), 16 bit mono (2 pins and a resistor network) or 16 bit stereo (4 pins and 2 resistor networks).

I use the 8 bit mono for sound effects and that's plenty good enough for my requirements.

For like a Storm trooper type effect?

Im not sure this is really going to help..seems to be more 'pitch' related.. (and I think uses the Waveshiled as a base)

but I have got this working before:

Just use the noise bit out of this program:-

 volatile unsigned int sample = 0;
 volatile unsigned int increment = 0x800;

void setup(){
    setSampleTimer();
}

ISR(TIMER2_COMPB_vect){  // Interrupt service routine to output next sample to PWM
      sample += increment;
     if((sample & 0x8000) != 0)  // implement a triangle wave
     OCR2B = 127 - (sample >> 8) & 0x7f;
     else
      OCR2B = (sample >> 8) & 0x7f;
}

void setSampleTimer(){  // sets timer 2 going at the output sample rate
  pinMode(3, OUTPUT);
  TCCR2A = _BV(COM2B1) | _BV(WGM21) | _BV(WGM20); // Just enable output on Pin 3 and disable it on Pin 11
  TCCR2B = _BV(WGM22) | _BV(CS22);
  OCR2A = 129; // defines the frequency 120 = 16.13 KHz or 62uS, 124 = 15.63 KHz or 64uS, 248 = 8 KHz or 125uS
  OCR2B = 64;  // deines the duty cycle - Half the OCR2A value for 50%
  TCCR2B = TCCR2B & 0b00111000 | 0x2; // select a prescale value of 8:1 of the system clock
}

void loop(){
   wobble(10);
   delay(1000);
   sweepUp(200);
   sweepDown(200);
   noise(1000);
   delay(1000);
   notes(30); 
   delay(1000);
}

void wobble(int wobbles){
   TIMSK2 = _BV(OCIE2B); // sound
    for(int j=0; j<wobbles; j++){
  for(int i = 0x500; i< 0x1300; i+=0x4){
    increment = i;
   delayMicroseconds(100);
  }
  }
  TIMSK2 = 0; // hush
}

void noise(int length){ // length about 1000
     TIMSK2 = _BV(OCIE2B); // sound
  for(int i=0; i<length; i++){ // noise
   increment = random(30, 0x1500);
   delayMicroseconds(100);
 }
   TIMSK2 = 0; // hush
}

void sweepUp(int time){ // time controls how long it takes start with 200
  TIMSK2 = _BV(OCIE2B); // Output Compare Match B Interrupt Enable
  for(int i = 0x500; i< 0x1300; i+=0x1){
    increment = i;
   delayMicroseconds(time);
 }
 TIMSK2 = 0; // Output Compare Match B Interrupt Disabled
}

void sweepDown(int time){ // time controls how long it takes start with 200
  TIMSK2 = _BV(OCIE2B); // Output Compare Match B Interrupt Enable
  for(int i = 0x500; i< 0x1300; i+=0x1){
    increment = 0x1300 - i;
   delayMicroseconds(time);
 }
 TIMSK2 = 0; // Output Compare Match B Interrupt Disabled
}

void notes(int length){
  TIMSK2 = _BV(OCIE2B); // sound
  for(int i=0; i<length; i++){
    increment = random(300,0x1500);
    delay(100);
  }
  TIMSK2 = 0; // hush
}

How would you include that? New to this, already got a working wave shield that distorts, but need a static burst at the end.

How would you include that?

With a wave shield you wouldn't. That was stand alone code, not designed to be used with a wave shield.

Lost now- is there a sketch that distorts voice, and I can put a static burst in? I've searched to no avail...

The point about an Arduino is that you can create your own projects. If you can't find one to copy that is good. That means when you create it you have added something to the project not just been a parasite.

I don't think a 16MHz Arduino is fast enough to capture audio, process it live, and output it again. Maybe a Teensy 3.1 or a Due.

Or use an analog method to accomplish this, but gated/controlled by the Arduino.

One of the types of distortion you nearly always hear is caused by compressing the audio to decrease the PEP to average power output. So... merely compressing the audio will accomplish that.

A bit of noise can be added, and gated louder for the post-transmission presquelch burst.

SSB frequency distortion is a bit more work. You need to shift the frequencies slightly up or down, preferably not staying the same. A couple of balanced oscillators and a tight bandpass filter could do this, but it is a bit more work.

I don't think a 16MHz Arduino is fast enough to capture audio, process it live, and output it again.

Yes it is.

I demonstrated at the Rome Maker fair last year a project that did exactly that. It had several modes, delay, echo, multiple echo, and frequency shift up and down without altering the speed, finally real time backwards output.

Very cool. Link?

polymorph:
Very cool. Link?

Not got one yet. It was going to be in a book, I got half way through writing it and the publisher pulled out. So I am looking for a new one.

They objected to some projects because they could not spend the money repeating them, like the Harp player that used 10 scrap CD drives.

I also showed it at the Newcastle Maker fair earlier in the same year.

Grumpy_Mike:
The point about an Arduino is that you can create your own projects. If you can't find one to copy that is good. That means when you create it you have added something to the project not just been a parasite.

I think someone thats new to the arduino family shouldn't be described as a "Parasite"- that smacks a bit of elitism. I just wanted to learn how to do it, and incorporate it into the other bit of the project I'm building for a stormtrooper helmet all-in-one. So far, fans switching on and off via a capacative switch, or temperature sensor. Shall I keep it quiet in future. oh lauded one? :slight_smile:

You would get more sympathy if you had read the forum rules and had not hijacked an old thread.

Sympathy? Didn't come here for that, I came for some tech advice.
Carry on.

Didn't come here for that, I came for some tech advice.

Well go away again until you learn some manners and feel like actually doing us the courtesy of behaving properly and obeying the rules we have around here.

Grumpy_Mike:
Well go away again until you learn some manners and feel like actually doing us the courtesy of behaving properly and obeying the rules we have around here.

Maybe, sir,you should take your own advice. BEng, IEE, MCSE, 15 C&G (185, 224), zilog programmer back in the day, I think I know netiquette inside out. The idea is you learn from Sketches put up (or be a parasite, you decide the grammar used), then as you develop, post the code up for the community to use, and probably move forward- the beauty of open source. Linux- a thing of beauty, brought forward by the sharing of many minds toiling away to produce an OS that anyone could push forward through mutual collaboration. Your attitude will drive "n00bs" away, as they will feel they cannot ask a question without getting flamed. I can quite adequately write what I need to to do what I require, in fact, since the post about noise, I have decided to go on a different path with a waveshield and a visduino, instead of an all in one. But I'm buggered if I'll post it up, as you decided it was "being a parasite".
Sayanora.

How would I make the noise part of this run on timer1, so I don't interfere with tone()? I tried it myself, but I've yet to master Arduino register bits :wink:

Thanks!

...R

Grumpy_Mike:
Just use the noise bit out of this program:-

 volatile unsigned int sample = 0;

volatile unsigned int increment = 0x800;

void setup(){
   setSampleTimer();
}

ISR(TIMER2_COMPB_vect){  // Interrupt service routine to output next sample to PWM
     sample += increment;
    if((sample & 0x8000) != 0)  // implement a triangle wave
    OCR2B = 127 - (sample >> 8) & 0x7f;
    else
     OCR2B = (sample >> 8) & 0x7f;
}

void setSampleTimer(){  // sets timer 2 going at the output sample rate
 pinMode(3, OUTPUT);
 TCCR2A = _BV(COM2B1) | _BV(WGM21) | _BV(WGM20); // Just enable output on Pin 3 and disable it on Pin 11
 TCCR2B = _BV(WGM22) | _BV(CS22);
 OCR2A = 129; // defines the frequency 120 = 16.13 KHz or 62uS, 124 = 15.63 KHz or 64uS, 248 = 8 KHz or 125uS
 OCR2B = 64;  // deines the duty cycle - Half the OCR2A value for 50%
 TCCR2B = TCCR2B & 0b00111000 | 0x2; // select a prescale value of 8:1 of the system clock
}

void loop(){
[SNIP]
  noise(1000);
[SNIP]
}

[SNIP]

void noise(int length){ // length about 1000
    TIMSK2 = _BV(OCIE2B); // sound
 for(int i=0; i<length; i++){ // noise
  increment = random(30, 0x1500);
  delayMicroseconds(100);
}
  TIMSK2 = 0; // hush
}

[SNIP]

Grumpy_Mike:
Well go away again until you learn some manners and feel like actually doing us the courtesy of behaving properly and obeying the rules we have around here.

Have you considered taking your own advice?

@charliesixpack
I notice that you are not rushing to help these thread hijackers. Go on tell them the answer I dare you.