Sign in to follow this  
Followers 0
botanic

Parse Data in txt file

1 post in this topic

#1 ·  Posted (edited)

I have a midi converted to txt file (shown below) and I need to convert it into a program like this:

(this is using the line in the first Track 3: 0 |(Off) Note | chan= 1 | pitch=f#4

|On Note | chan= 1 | pitch=E 4 | vol=110)

function F_S_4_1 takes nothing returns nothing

local timer T = GetExpiredTimer()

call PauseTimer(T)

call ReleaseTimer(T)

call StopSoundBJ( udg_Sound[1], false )

endfunction

function Track_1 takes nothing returns nothing

local timer T1 = NewTimer()

local integer Track = 1

local sound S

set S = udg_F_S_4

call PlaySoundBJ( S )

call SetSoundVolumeBJ( S, 100 )

set udg_Sound[Track] = S

call TimerStart(T1, .25, true, function F_S_4_1())

set T1 = null

endfunction

my problems are that I have no idea how to get the values I need. Also the F_S_4_1 needs to become F_S_4_2 in track 2 ect. The bold part will be the part that sets the note from the value.

Pretty much I have 3 questions:

1) How do I get the data

2) How do I write the data in order (all the "F_S_4_1" functions have to be above the Track_1 function

3) how do i get the time value "ex> 2: 1: 0" and convert it to a time (used instade of the .25)

MThd | Format=1 | # of Tracks=5 | Division=192

Track #0 ******************************************
    Time       Event
   1: 1:  0 |Text    | len=20   |
        0x42 0x79 0x20 0x55 0x6E 0x72 0x65 0x67 0x69 0x73 0x74 <By Unregist>
        0x65 0x72 0x65 0x64 0x20 0x55 0x73 0x65 0x72       <ered User>
        |Copyright   | len=64   |
        0x43 0x6F 0x70 0x79 0x72 0x69 0x67 0x68 0x74 0x20 0xA9 <Copyright .>
        0x20 0x31 0x39 0x39 0x38 0x20 0x62 0x79 0x20 0x4E 0x6F < 1998 by No>
        0x74 0x65 0x57 0x6F 0x72 0x74 0x68 0x79 0x20 0x41 0x72 <teWorthy Ar>
        0x74 0x57 0x61 0x72 0x65 0x2C 0x20 0x49 0x6E 0x63 0x2E <tWare, Inc.>
        0x0D 0x41 0x6C 0x6C 0x20 0x52 0x69 0x67 0x68 0x74 0x73 <.All Rights>
        0x20 0x52 0x65 0x73 0x65 0x72 0x76 0x65 0x64       < Reserved>
        |Text    | len=32   |
        0x47 0x65 0x6E 0x65 0x72 0x61 0x74 0x65 0x64 0x20 0x62 <Generated b>
        0x79 0x20 0x4E 0x6F 0x74 0x65 0x57 0x6F 0x72 0x74 0x68 <y NoteWorth>
        0x79 0x20 0x43 0x6F 0x6D 0x70 0x6F 0x73 0x65 0x72      <y Composer>
        |Key Sig     |  D Major  |
        |Tempo   | BPM=110   | micros\quarter=545454
        |End of track| 

Track #1 ******************************************
    Time       Event
   1: 1:  0 |Device Name | len=31   |
        0x4D 0x69 0x63 0x72 0x6F 0x73 0x6F 0x66 0x74 0x20 0x47 <Microsoft G>
        0x53 0x20 0x57 0x61 0x76 0x65 0x74 0x61 0x62 0x6C 0x65 <S Wavetable>
        0x20 0x53 0x57 0x20 0x53 0x79 0x6E 0x74 0x68       < SW Synth>
        |Text    | len=19   |
        0x4D 0x69 0x67 0x68 0x74 0x20 0x26 0x20 0x4D 0x61 0x67 <Might & Mag>
        0x69 0x63 0x20 0x28 0x4E 0x45 0x53 0x29        <ic (NES)>
        |Track Name  | len=19   |
        0x4D 0x69 0x67 0x68 0x74 0x20 0x26 0x20 0x4D 0x61 0x67 <Might & Mag>
        0x69 0x63 0x20 0x28 0x4E 0x45 0x53 0x29        <ic (NES)>
        |Instrument  | len=19   |
        0x4D 0x69 0x67 0x68 0x74 0x20 0x26 0x20 0x4D 0x61 0x67 <Might & Mag>
        0x69 0x63 0x20 0x28 0x4E 0x45 0x53 0x29        <ic (NES)>
        |Program     | chan= 1   | pgm #= 69 Oboe
        |Controller  | chan= 1   | contr=Volume H | value=127
        |Controller  | chan= 1   | contr=Pan H | value= 64
        |On Note     | chan= 1   | pitch=F#4     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=f#4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
   2: 1:  0 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=C#4     | vol=110
   3: 1:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
   4: 1:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=C#4     | vol=110
   5: 1:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=C#4     | vol=110
   6: 1:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
   7: 1:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
   8: 1:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
   9: 1:  0 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
  10: 1:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
  11: 1:  0 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=B 2     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=b 2
        |On Note     | chan= 1   | pitch=D 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
  12: 1:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
  13: 1:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=C#4     | vol=110
  14: 1:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=F#4     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=f#4
        |On Note     | chan= 1   | pitch=A 4     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=a 4
        |On Note     | chan= 1   | pitch=A 3     | vol=110
  15: 1:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
  16: 1:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=D 4     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     24 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
     48 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     72 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
    120 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
    144 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
    168 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     24 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
     48 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     72 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=C#4     | vol=110
  17: 1:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=C#4     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=D 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=C#3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=c#3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
  18: 1:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=D 4     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=C#4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=C#4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=F#4     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=f#4
        |On Note     | chan= 1   | pitch=A 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=a 4
        |On Note     | chan= 1   | pitch=B 4     | vol=110
  19: 1:  0 |(Off) Note  | chan= 1   | pitch=b 4
        |On Note     | chan= 1   | pitch=G 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=g 4
        |On Note     | chan= 1   | pitch=F#4     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=f#4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=G 4     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=g 4
        |On Note     | chan= 1   | pitch=F#4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=f#4
        |On Note     | chan= 1   | pitch=E 4     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=e 4
        |On Note     | chan= 1   | pitch=D 4     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=d 4
        |On Note     | chan= 1   | pitch=C#4     | vol=110
  20: 1:  0 |(Off) Note  | chan= 1   | pitch=c#4
        |On Note     | chan= 1   | pitch=B 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
  21: 1:  0 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=D 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=d 3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=E 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=e 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
  22: 1:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=B 3     | vol=110
      2:  0 |(Off) Note  | chan= 1   | pitch=b 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      3:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=A 3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=a 3
        |On Note     | chan= 1   | pitch=G 3     | vol=110
      4:  0 |(Off) Note  | chan= 1   | pitch=g 3
        |On Note     | chan= 1   | pitch=F#3     | vol=110
     96 |(Off) Note  | chan= 1   | pitch=f#3
        |On Note     | chan= 1   | pitch=E 3     | vol=110

ect ect...
Edited by botanic

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0