Search the Community
Showing results for tags 'music'.
Found 4 results
New to msp430. I trying to make it buzz a tone through a piezo speaker I have plugged into 1.4. I want it to change pitch a few times but can't figure out to control the duration. How can I make the tone hold for one sec before incrementing? Here's the code I've written so far. I'm trying to do the increment in a loop. #include "msp430.h" ; #define controlled include file NAME main ; module name PUBLIC main ; make the main label vissible ; outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label RSEG CSTACK ; pre-declaration of segment ;define all notes as global constants RSEG CODE ; place program in 'CODE' segment init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer BIS.B #LFXT1S_2, &BCSCTL3 ; enable Very Low Frequency Oscillator (VLO)mode BIC.B #OFIFG, &IFG1 ; clear flags for IFG1 BIS.W #(SCG0+SCG1), SR ; TURN OFF DCO, AND SMCLK BIS.B #SELM_3, &BCSCTL2 ;SELECT VLO TO SOURCE MCLK MOV.W #CCIE, &TACCTL0 ; MOV.W #40, &TACCR0 ; MOV.W #TASSEL_1+MC_1, &TACTL ; BIS.B #1h, &P1DIR BIS.B #10h, &P1DIR ; p1.4 ouT ;LOOP: MOV.W &TACCR0+10, &TACCR0 ;NEW PITCH jmp LOOP ; Again ;DELAY ONE SECOND BIS.W #CPUOFF+GIE,SR ;CPU OFF, INTERRUPTS ENABLED JMP LOOP ; jump to current location '$' TA0_ISR: XOR.B #001h, &P1OUT XOR.B #10h, &P1OUT ;NEED TO CLEAR FLAG RETI COMMON INTVEC ORG TIMER0_A0_VECTOR DW TA0_ISR ; (endless loop) END
I'm new to the msp430 and I want to make it play a song through a speaker when I push the button. However, I want to do this with assembly code and not in C. I am using IAR embedded workbench to do my programming. I'm connecting a speaker directly to the msp430 at p1.3 and ground. Are there any tutorials on how to do this? Or any assembly code I could look at that does something similar? I looked through the forum topics but could not find anything that matched with what I'm trying. thanks, alanaxis
I've been looking for a while and can't find a good example showing how I can play any sort of music or speech files (mp3, au, wav, etc.). I've got a configuration setup that allows me to read files for things like LCD screens, I'm looking to read a music or speech file and play it through an amplified speaker. I'm not looking to make just tones, rather to play full music or speech files. I've found projects for Arduino such as (http://hlt.media.mit.edu/?p=1963), but nothing that works with MSP430 and Energia. Has anyone done something similar to this with Energia?
I decided to have a crack at building some drum pads, because the keyboard that I'd acquired for the kids to learn piano on had a midi input, and somewhat acceptable drum sounds to boot. After several months of sitting around half-completed under a cupboard, I decided to pull it out over the easter weekend and actually make it work. In words, here's what I did. Six drum pads, made of a square of hardboard with 5mm closed-cell foam glued to the top and standing on 15mm foam pads. Each pad has a piezo electric transducer underneath, attached using hot glue. These six piezos are each hooked up to a buffer and biasing and clamping circuit, like below. The op-amp I used was an LMC648, which is great for this application but isn't that cheap. These six analog channels are connected to six of an MSP430's analog inputs. This micro samples these six inputs continuously, and uses a simple filter and threshold algorithm to determine when they've been hit. Once it detects a hit, it outputs the pad ID (zero to five) and the 'velocity' of the hit over I2C to another MSP430. This second micro in turn outputs the MIDI command, through a completely un-necassary additional chip to drive the MIDI output completely to spec. I know it's possible to output midi using 3.3v, but I used a driver chip anyway to run it at 5v - a TC4428 FET driver that I happened to have left over from another project. The second micro also translated the pad ID to a MIDI note, and can be reprogrammed via a couple of buttons that are used to change the drum sound that's assigned to the most recently hit pad. The assignments are stored in the MSP430's "information memory" segment, so that it remembers how you set it up when you turn it off. I'd originally planned to put a 16x2 LCD on there, but I ended up using that for something else. In pictures, here's what it looks like. Overall: PCB closeup - I would normally have a full eagle schematic and layout for this, even if I'm building it on stripboard, because I just make fewer mistakes that way. In this case though the layout of the six clamping circuits turned out to be much easier if I stood those components up out of the board (look on the right side of the picture) and wired them up over the top, and you can't really do that so easily in Eagle. Piezo closeup (under the pads) And finally, in code, here's the two projects. The ADC sampling micro : main.c The MIDI outputting micro : main.c Probably the most interesting aspect of this for me at least, was that when I was designing the (admittedly still rather crude) algorithm to determine how hard the pad had been hit, I needed to get the ADC samples off the chip so that I could experiment with algorithms offline and tweak their performance. I happen to have one of the rather wonderful saleae USB logic analysers (https://www.saleae.com/logic/), and so if you compile the ADC sampling micro's code with OUTPUT_SAMPLES defined, it will run the I2C at 1Mhz (instead of a much more reasonable 125kHz) and output all the ADC data as it receives it. This is pretty borderline for I2C, but if you keep the track length for the I2C nice and short you should be ok. In my case it's the orange and yellow wires in the PCB photo above - and of course you'll need both micros there because the I2C won't work if nothing's there to ACK. Anyway, doing this I was able to get the samples back into my PC, and using python and pylot etc, plot handy graphs like this: Python file, and two text files recorded from the inputs using I2C and the USB logic analyser : Archive.zip The algorithm just detects when the input rises over some threshold, and while integrates the value before it crosses back over zero again (this is after the ADC samples have had 512 subtracted from them of course, making them signed). This is then considered the 'velocity', and the MIDI micro then divides that down to get a 7-bit velocity value for MIDI. This works 'ok', but very light hits aren't detected, and sometimes hits are quite a bit louder than you'd expect. It's still fun though.