comp music with pic Sounds - Aka BeepMaster


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    65

    Default comp music with pic Sounds - Aka BeepMaster

    Ok, here's one little thing I came to spend time on and turned out to be quite funny, so for the musician, here you go:

    I wanted an easy-er way to create tunes with the sound command, else than testing/programming over 40 times to get the notes right.
    Initial plan was to create everything from a windows apps, then output notes to pic, but finally I was tempted to use the PIC as a sound card...

    Result is, a small application running under windows, showing you a virtual music keyboard and notes supported by the PB sound command.(I did my best to match the real frequencies with the ones emitted by a PIC, but they are not all 100% accurate).
    You can clic the keyboard, and notes will be sent on the serial port to the PIC for playback.
    Of course you can record/delete clicked notes to a list, and in the end ask the software to output a PBasic command line to put into a program.



    not 100% bulletproof tested, but functionnal over here.
    Made at least 6 tunes in less than 15 minutes with it.
    It come pre-loaded with JS Bach Minuet =)

    program EXE is here:
    http://www.flipperdesign.com/BeepMaster.rar


    Code required in the PIC to get the notes is here:

    Code:
    ; sound generator PIC12F683, @20Mhz
    ; testing Sounds, and they wait for Data from seial to play more..
    ; For use with BEEPMaster.exe Program to create tunes
    
    '-------------------------------------------------------------------
    ' PIC12F683 
    '-------------------------------------------------------------------
    ' PIN  NAME     USE/CONNECTION
    '  1   Vdd      +5VDC
    '  2   GPIO.5   XT
    '  3   GPIO.4   XT
    '  4   GPIO.3   N/C, MCLR
    '  5   GPIO.2   LED OUTPUT
    '  6   GPIO.1   SERIAL INPUT
    '  7   GPIO.0   SPEAKER OUTPUT, with a small caps 
    '  8   VSS       GROUND
    '-------------------------------------------------------------------
    
    DEFINE DEBUG_REG GPIO
    DEFINE DEBUG_BIT 1          ' GPIO.1
    DEFINE DEBUG_MODE 0         ' 1 = inverted, 0 = true
    DEFINE DEBUG_BAUD 38400     ' test 38400(fonctionne pas toujours sur le INTOSC)
    
    DEFINE DEBUGIN_REG GPIO
    DEFINE DEBUGIN_BIT 2          ' GPIO.2
    DEFINE DEBUGIN_MODE 0         ' 1 = inverted, 0 = true
    
       DEFINE OSC 20
    
       CMCON0 = 7 'Analog Comparators OFF
       ANSEL   = %00000000   ' Set A/D OFF, necessaire pour SOUND!
       ADCON0 = %00000000 'Analog converter OFF(test) 
    
       WPU = 0  ' Internal pull-ups = off, maybe REQUIRED for MCLR_OFF
    
    INPUT GPIO.2
    OUTPUT GPIO.1
    
    Speaker var GPIO.0
    output Speaker
    
    Freqtest var Word
    
    Duration var byte
    
    curNote var byte
    
    ;LedPort var GPIO.2
    ;Output Speaker
    
    dlzic var byte
    
    curNote=0
    
    ;High LedPort
    Pause 200
    
    dlzic=40
    
    pause 100
    sound Speaker,[105,dlzic,99,dlzic,102,dlzic,90,dlzic*2,0,15,90,dlzic,102,dlzic,105,dlzic,99,dlzic ]
    
    
    ; Super Cool warp!
    for Freqtest= 200 to 600
       FREQOUT Speaker,10,Freqtest
       next Freqtest
    
    ;High LedPort
    
    ; NOW that fun is over, lets wait for client input
    
    waitforkeydata:
    pause 1
    DEBUGIN [WAIT("DT")]
    DEBUGIN [HEX2 curnote]
    DEBUGIN [WAIT(",")]
    DEBUGIN [HEX2 duration]
    DEBUGIN [WAIT(13)]  ; wait carriage return
    
    pause 2
    
    sound Speaker,[curnote,duration ]
    
    ;High LedPort
    
    GOTO waitforkeydata
    
    END

    note: The windows BEEP option to have sounds played under windows does not work with all computers... here.
    Last edited by flipper_md; - 30th October 2009 at 21:42. Reason: .

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Now that is an interesting project!!!
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink nice jewel ...

    Hi, Flipper

    Ha que voilà une application des plus sympas !!!

    Merci encore.

    PS: dis m'sieur ... on pourrait aussi avoir le bruit Blanc, histoire d'étendre le domaine d'utilisation aux bruitages ??? ...

    Merci d'avance.

    Alain

    PS: Sous XP SP3, les touches du clavier et la légende des cases à cocher n'apparaissent pas ...
    Last edited by Acetronics2; - 31st October 2009 at 17:10.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Salut Alain

    oh, no keys appearing?
    could you send a snapshot of what it looks like on your PC?
    flipperdesign at gmail ... dot

    this is hard to imagine as i'm forcing colors...but will check back what could cause that.

    White noise, yes it could be. Maybe on another piano bar.
    I've just added it for a quick test but it's not implemented with recording.
    you can redownload from the same link

    Thanks for the idea!

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Wonderfull project ! It is possible to use 12F675 instead 12F683 ? Thanks !

  6. #6
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    any PIC will do

    it just we to wait for the correct data to come in, which is set by the sending program.

    the only real important part is here:

    Code:
    waitforkeydata:
    pause 1
    DEBUGIN [WAIT("DT")]
    DEBUGIN [HEX2 curnote]
    DEBUGIN [WAIT(",")]
    DEBUGIN [HEX2 duration]
    DEBUGIN [WAIT(13)]  ; wait carriage return
    
    pause 2
    
    sound Speaker,[curnote,duration ]
    
    ;High LedPort
    
    GOTO waitforkeydata

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts