Shop OBEX P1 Docs P2 Docs Learn Events
Electronic Trumpet — Parallax Forums

Electronic Trumpet

wtvizzuttiwtvizzutti Posts: 8
edited 2005-12-13 19:49 in BASIC Stamp
I am trying to make a trumpet using the BS2 module. I would like to add midi out in the future, but for now all I want is to use simple audio out such as FREQOUT. I don't understand how to play the note only when it is supposed to be on. I attached my source that I have so far (no sound yet), and a list of the notes with their corresponding midi number, frequency, and register.

Any hints, sample code, or ideas are greatly appreciated,


Thanks,
Matt

Comments

  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-12 22:35
    I guess to ask it another way:

    How do I make FREQOUT's duration dependent on a button combination and then change with the combination?

    Are there other ways to produce frequencies with code?


    Matt
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-12 23:07
    Do you wish to play a note for the duration that a button is depressed, or a button has an associated duration. If it is the first, I fear you may find the BS an inadequate solution. FREQOUT works well when the duration is known in advance but not during the note playing. Someone correct me if I am wrong.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-12 23:25
    I want the note to sound for the duration a button is depressed. Thats the problem because I can't predefine the duration of FREQOUT. The duration will always be unique.

    If there were a way to stop FREQOUT when a new combination of buttons were pressed and start a new FREQOUT, then I could settle for a predefined duration. I would also need FREQOUT to stop as needed (if silence is needed before the predefined duration)
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-13 15:32
    No Im afraid there is no way to interrupt the playing of a note through the use of FREQOUT. FREQOUT works through pulse width modulating an output pin. You only hope would be to do the PWM yourself (through PULSOUT), but depending on the variety of stamp you are using you will have different levels of success. If you have the vanilla variety of the BS2, the best you could hope for would be a top frequency of 2 kHz (this is assymtotic, meaning you can approach it but cannot reach it), The assymtotic frequency of the fastest BS2 module (BS2px) using PULSOUT is 9.5 kHz. An SX using SX/B could easily do what you seek, but that would require investment in the SX development kit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-13 17:19
    Since a goal of the project is to add midi, what about playing directly to a midi ic and using the audio out from it? I have had no luck finding such a chip with google. I think this would be ideal because the sound would be more pleasing and have more choices.

    Any idea how to implement (or even find) such a midi ic?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-13 17:28
    Im not aware of any simple chips to do so (there are some chips which have a midi interface as a feature, but they are complex surface mount chips not really to to be fooled with by someone without a fair amount of skill). Now when you mentioned midi in your original post, were you refering that you wanted the BS2 to send midi commands, or to receive them?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-13 17:34
    I am just planning on sending midi signals. I have already found plenty of example code for that, but haven't tried implementing it in my code.

    I think a possibility for the midi audio out is usig a pda. I guess I'll be looking into this.

    Thanks
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-13 17:37
    The easiest way would be to do the sound generation through the midi interface, just send a "note on" command when a button is pressed, then send a "note off" command when it is released. A synth hooked up to the midi interface would play the trumpet sounds for you. Trying to read buttons, play notes and send midi is a little too much for a BS2 to handle.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • prprogprprog Posts: 18
    edited 2005-12-13 18:00
    I built a BS2-MIDI wind controller and will put the details (source code) and details shortly on the project forum. I am sure you can used the ideas to built your trumpet.··
  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-13 18:08
    Another goal I didn't mention is to be pocket sized. There are plenty of midi synthesizers available, but they are all too large to walk around with. What I am trying to create is an instrument that fits in my hand and in my pocket for playing anytime and most anywhere. I want to include a line thru to combine the trumpet with an mp3 player. This way I could play along with songs or without.

    I hope this project is more possible than it seems.
  • prprogprprog Posts: 18
    edited 2005-12-13 18:59
    Well you will be dissapointed with my MIDI Wind controller. It was not design/built for size (it actually looks like a clarinet) and the BS2 reside in a separate control box (because my goal is to be capable of changing MIDI controllers but the control box remain the same).
  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-13 19:04
    No, prprog, I'd really appreciate seeing what you have come up with! Please share it, I am thankful for all of the input I can get.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-13 19:06
    Ive done a brief look, but couldn't find anything that fits the bill, I think you'll have to switch to the SX to do what you want, but this application would require more than just straight up programming in SX/B (I think), meaning some assembly required (pun).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • prprogprprog Posts: 18
    edited 2005-12-13 19:10
    Can you explain a bit what a "register" means ?

    From the BS2 code comments:

    'The first pair raises and lowers the register.
    ' The second pair raises and lowers the octave.

    Also (since I dont play trumpet) I dont see how with 3 buttons and a register (and octave button) you can get a full set of notes.

    thanks
    ·
  • wtvizzuttiwtvizzutti Posts: 8
    edited 2005-12-13 19:49
    The register is how the notes are grouped on the trumpet. The top of the register is the first note and is achieved by not pressing any of the valves. The note is lowered by depressing the valves. With the 3 valves there are 7 possible pitches per register. First valve drops the pitch 2 semitones, second valve one semitone, and the third valve 3 semitones.

    The same notes may be produced from the different key combinations without changing the register (ex: v1 + v2 = v3).

    The registers do overlap the higher the note is. This overlap also causes there to be different valve combinations for the same note.

    I hope that explains it well, otherwise the registers and notes are outlined in the notes.txt attachment in the first post. The register overlap isn't evident until beyond halfway down.
Sign In or Register to comment.