OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

create and play a MIDI file ...

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
bertram
Power User
Power User


Joined: 13 Nov 2005
Posts: 55

PostPosted: Wed Apr 11, 2012 11:59 am    Post subject: create and play a MIDI file ... Reply with quote

1. is there a way to open a shell and execute a local .exe program from within a macro?

a macro could be used to write a text file to disk, for example "CloseEncounters.csv"
Code:
;the 5-note motif from Close Encounters of the Third Kind
;using an organ patch from the General MIDI instrument set
0, 0, Header, 1, 2, 480
1, 0, Start_track
1, 0, Title_t, "Close Encounters"
1, 0, Text_t, "Sample for MIDIcsv Distribution"
1, 0, Copyright_t, "This file is in the public domain"
1, 0, Time_signature, 4, 2, 24, 8
1, 0, Tempo, 500000
1, 0, End_track
2, 0, Start_track
2, 0, Instrument_name_t, "Church Organ"
2, 0, Program_c, 1, 19
2, 0, Note_on_c, 1, 79, 81
2, 960, Note_off_c, 1, 79, 0
2, 960, Note_on_c, 1, 81, 81
2, 1920, Note_off_c, 1, 81, 0
2, 1920, Note_on_c, 1, 77, 81
2, 2880, Note_off_c, 1, 77, 0
2, 2880, Note_on_c, 1, 65, 81
2, 3840, Note_off_c, 1, 65, 0
2, 3840, Note_on_c, 1, 72, 81
2, 4800, Note_off_c, 1, 72, 0
2, 4800, End_track
0, 0, End_of_file

Can I then open a shell and run a small local executable on that file?

fourmilab.ch has a utility that will convert csv to midi ... found at http://www.fourmilab.ch/webtools/midicsv/#csvmidi.1)
Code:
shell( "csvmidi.exe CloseEncounters.csv CloseEncounters.mid")


for music studies, it would neat to be able to write a macro that generates a midi file based on values in a spreadsheet ...

2. If I can get a shell to run the .exe, then is it possible to play a midi file by a command from a macro or a dialog?

thanks if you have any thoughts!!
Back to top
View user's profile Send private message
DVezina
OOo Advocate
OOo Advocate


Joined: 29 Sep 2006
Posts: 248
Location: Orlando

PostPosted: Wed May 02, 2012 10:42 am    Post subject: Reply with quote

Yes it is possible to execute a program from a macro using the shell function.
I'm using OO 3.3/Writer/Macros(StarBasic)
Shell (Pathname As String[, Windowstyle As Integer][, Param As String][, bSync])

Code:


Sub playMusic
' create your .csv file here

' convert .csv to .mid
shell( "csvmidi.exe",1,"CloseEncounters.csv CloseEncounters.mid",true)
'true waits for shell to complete before moving on

' play file - this assumes .mid file type is associated to correct program
' or you can use shell again

sURL = convertToURL("C:\CloseEncounters.mid")
oSvc = createUnoService("com.sun.star.system.SystemShellExecute")
oSvc.execute(sURL,"",0)

End Sub

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group