comp music with pic Sounds - Aka BeepMaster


Closed Thread
Results 1 to 19 of 19
  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 22: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,611


    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 18: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
    575


    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

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    575


    Did you find this post helpful? Yes | No

    Default

    Merci beaucoup !

  8. #8
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    a quick note to let you know that there is a visual bug under any OS that is set to use the fancy windows themes, like rounded buttons and fades...

    to get things right, you new to switch into Perfomance mode under XP, or set the theme to "Classic" in Win7. Yah, it will reminds you of the good old Win2000 days

    that is until I find a way to set colors properly into that fancy world.

    thanks goes to Brad for help finding this out.

  9. #9
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default new version

    You can now re-download from the same link, and a newer version is there. Look in the top right corner options if you can't see the interface.

    try barbie pink interface!! it's NIce


    also fixed a bug with noise notes code, that would try to send data even if PIC option was not selected.

  10. #10


    Did you find this post helpful? Yes | No

    Default Wow

    Hi Flipper

    WOW this really is something !

    You know anyone could (with some tweaking to a Jean Michel Jarre with a PIC !

    Combine your PIC code with something Skimask was busy on [HTML]http://www.picbasic.co.uk/forum/showthread.php?t=5407&highlight=finger+touch[/HTML] and maybe a few Led's and a laser pointer or two and whammo you have a hit !
    In fact , interface your Windows proggie with a media player, feed it to the same sound source and you have an LED touch DJ panel with sound to light !

    I will keep an eye out for it !

    Many thanks

    Kind regards
    Dennis

  11. #11
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    agreed that possibilities are totally endless


    I already hooked a frequency bargraph on my board right aside, since I needed a frequency analyser to catch the sounds emitted by the pic in the first place.


    here is a newer Beta version, with Basic MIDI output, and some other tweak.
    http://www.flipperdesign.com/BeepMaster_midi.rar

    watch out, it could be pretty loud and there no volume control
    But i do like the midi sounds...a bit more than the PC beeper LOL

  12. #12


    Did you find this post helpful? Yes | No

    Default some food for thought :-)

    Hey Flipper

    Awesome !!
    Will give it a shot and feedback when I can :-)
    Maybe a light organ ??
    [HTML]http://www.picbasic.co.uk/forum/showthread.php?t=5407&highlight=finger+touch[/HTML]
    .....Or touch-sensitive :-)
    Think the light-organ would be something even more quite unique as an add-on or option for your code (or new code!)

    Would love to try it out if ever you get to do it !

    Dennis

  13. #13
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Hi Dennis

    I'm not too sure on how things would get hooked between light sensor/program/ and another pic making sound?, but if you can describe the loop I might check into it.

    I would hope to add multitrack capability one day, or maybe easier and more powerfull, a plain Midi track importer/converter.
    Then a whole bunch of 12f683 would share the data, singing along


    here is a light organ, sort of

    [HTML]http://www.youtube.com/watch?v=aOZEpP_zzaw[/HTML]

    i've just added it into my program, as default sample track.

  14. #14
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    updated program recently, some added functions and checks.

    and created a new utility to process midi files for import(work ok with clean tracks, ie no multi-tones as the pic can't do that)


    more info in this web page:
    http://www.flipperdesign.com/projects_beepmaster.html

  15. #15
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Very cool, except that I can't get it to work, if I press any key (on the little piano-keayboard) that has a decimal point I get the error message "xxx.xxx is not a valid floating point value"


    I GUESS that this can be due to that the official floating point marker in Sweden is comma (,) and not a dot (.) (even if many people use a dot anyway).

    Would it be possible to fix this bug ? probably by reading that info from windows in some way ? ..it's actually the first time I seen this problem.

  16. #16
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    thanks for reporting this error Glenn

    I believe you have pinpoint the bug. my programming didn't checked for coma or point separator.
    Now it will update the frequency list at startup, after checking system settings.
    (a message will appear in the application title area)

    please redownload BeepMaster_midi.rar and let me know.

  17. #17
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Sorry for the late reply, but it works much better now

    But I still cant get it to convert a MIDI file, but since I'm not very good at MIDI files and you make some notes about what's supportet I guess it's my file that is the problem..

  18. #18
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    good!

    check back on my website(scroll way down), as I updated some information about midi stuff.
    If you have other question on un-explained stuff just ask, I will try to update the info.


    DS

  19. #19
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    updated version with some more control is now available

    http://www.flipperdesign.com/BeepMaster2010grid.rar

    don't be afraid to Right Click over grids and buttons, they will often reveal magic functions

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 11:00
  2. Replies: 67
    Last Post: - 8th December 2009, 03: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, 15: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, 22:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th March 2005, 00: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