mitxela.com forum
Welcome. Please log in or register.

using python
DAVID Posted: 15 Jul 2018, 01:17 PM
Avatar
I love mcus

Member
Posts: 237
Joined: 10-September 17
hi i recently found a py file that its purpose is:
(firstly you need to convert a midi file into a h file with this tool https://bitbucket.org/kevinbchen/musicbox/src/ff56789bcbd7367fb25f56f6c7e756dacef7b602/util/MidiToC.exe?at=master&fileviewer=file-view-default)
so you execute the .py file (https://bitbucket.org/kevinbchen/musicbox/src/ff56789bcbd7367fb25f56f6c7e756dacef7b602/util/midi.py?at=master&fileviewer=file-view-default) and what it should do is you paste the header that has been copied by the MiditoC.exe and then export a .h file but i could not get it to work.
Can somebody help me??

-------------
[top]
mit Posted: 17 Jul 2018, 02:11 PM
Avatar
yeah whatever

Admin
Posts: 551
Joined: 4-May 16
Hi, sorry I think you'll need to explain more for me to help. Where did you get those links, is there a site that explains it? Might be best asking the person who wrote it.

-------------
[top]
DAVID Posted: 18 Jul 2018, 09:16 AM
Avatar
I love mcus

Member
Posts: 237
Joined: 10-September 17
http://blog.kevinbrianchen.com/2014/07/music-box.html

-------------
[top]
mit Posted: 20 Jul 2018, 10:33 PM
Avatar
yeah whatever

Admin
Posts: 551
Joined: 4-May 16
OK. Well, how far have you got? There's no source for the .exe file so I can't help with that, but I can see what the python file is trying to do. Did you get a .h file out of the exe file then?

If you are on windows you will need to install python to run the script, it looks like python 2.7 (because there are no brackets around the print calls), python 3 will throw an error about that. There doesn't seem to be any dependencies so you don't need to worry about installing modules, which is sometimes a pain.

-------------
[top]
DAVID Posted: 20 Jul 2018, 11:36 PM
Avatar
I love mcus

Member
Posts: 237
Joined: 10-September 17
ok but i tried and it did not work on windows 7
so maybe trying it in ubuntu will work

-------------
[top]
DAVID Posted: 21 Jul 2018, 12:49 AM
Avatar
I love mcus

Member
Posts: 237
Joined: 10-September 17
QUOTE (mit)
OK. Well, how far have you got? There's no source for the .exe file so I can't help with that, but I can see what the python file is trying to do. Did you get a .h file out of the exe file then?

yes i got it but still wen it says "paste from MidiToC program" and i paste it nothing happens


-------------
[top]
DAVID Posted: 21 Jul 2018, 12:50 AM
Avatar
I love mcus

Member
Posts: 237
Joined: 10-September 17
here is what there is in the .h file:
#include "melody.h"

//Player frequency=18000
//Player minimum channels count =15
const flash uint8_t s_melody_stream[833] = {
200,
32,
88,
179,
16,
0,
0,
128,
10,
208,
106,
45,
197,
97,
51,
48,
2,
192,
30,
10,
228,
0,
160,
13,
152,
55,
9,
97,
33,
26,
146,
227,
126,
175,
9,
248,
57,
166,
60,
25,
163,
76,
120,
51,
70,
145,
122,
166,
60,
25,
163,
76,
120,
51,
70,
152,
240,
102,
184,
175,
143,
6,
104,
241,
95,
30,
12,
209,
226,
188,
94,
184,
175,
143,
6,
104,
241,
95,
30,
12,
209,
226,
212,
87,
30,
12,
209,
174,
60,
25,
163,
88,
189,
87,
30,
12,
209,
174,
60,
25,
163,
92,
16,
113,
122,
46,
47,
69,
197,
233,
197,
232,
191,
22,
162,
66,
8,
200,
65,
25,
8,
41,
8,
35,
33,
4,
100,
32,
156,
65,
23,
16,
69,
196,
19,
136,
34,
226,
8,
184,
130,
144,
130,
50,
16,
70,
66,
10,
66,
8,
200,
65,
25,
8,
39,
16,
69,
196,
17,
113,
4,
226,
8,
184,
226,
214,
170,
99,
54,
52,
198,
108,
85,
34,
245,
76,
120,
51,
70,
158,
15,
227,
54,
60,
32,
211,
25,
212,
220,
87,
198,
108,
120,
175,
140,
216,
174,
43,
197,
235,
138,
248,
240,
102,
143,
21,
252,
31,
198,
108,
120,
65,
226,
212,
85,
92,
102,
198,
184,
205,
138,
172,
94,
171,
143,
6,
104,
215,
194,
12,
102,
199,
131,
250,
249,
53,
97,
83,
142,
77,
216,
184,
228,
221,
138,
113,
122,
113,
122,
47,
194,
15,
22,
188,
31,
138,
184,
184,
228,
178,
124,
218,
208,
220,
150,
79,
155,
90,
25,
25,
8,
41,
8,
35,
33,
4,
100,
33,
87,
39,
46,
57,
181,
160,
184,
230,
214,
130,
153,
196,
19,
136,
34,
226,
8,
184,
133,
92,
156,
72,
115,
107,
65,
144,
230,
214,
130,
154,
66,
10,
66,
8,
200,
65,
25,
8,
85,
201,
203,
142,
109,
104,
46,
57,
181,
160,
166,
113,
4,
226,
8,
184,
226,
214,
170,
120,
63,
140,
216,
211,
194,
12,
102,
199,
132,
42,
71,
38,
252,
33,
181,
60,
35,
70,
108,
105,
198,
51,
99,
133,
49,
159,
9,
173,
197,
126,
17,
155,
30,
43,
248,
79,
140,
216,
225,
197,
120,
228,
223,
22,
226,
190,
51,
99,
197,
124,
102,
197,
113,
106,
56,
77,
175,
8,
205,
141,
120,
198,
108,
120,
70,
172,
114,
111,
194,
27,
87,
194,
20,
102,
198,
190,
16,
99,
54,
60,
31,
215,
201,
171,
14,
16,
223,
132,
33,
201,
187,
23,
225,
4,
114,
110,
199,
131,
247,
28,
155,
212,
206,
57,
55,
98,
252,
90,
161,
194,
15,
23,
252,
156,
115,
89,
209,
229,
221,
90,
219,
71,
53,
151,
117,
107,
109,
8,
181,
146,
16,
82,
16,
70,
66,
8,
200,
67,
148,
29,
42,
232,
229,
199,
86,
182,
151,
29,
90,
218,
83,
81,
99,
136,
39,
16,
69,
196,
17,
113,
14,
80,
116,
171,
163,
137,
14,
173,
109,
50,
29,
90,
218,
83,
81,
100,
132,
20,
132,
17,
144,
130,
50,
16,
229,
7,
74,
186,
57,
113,
213,
173,
165,
199,
86,
182,
148,
212,
88,
226,
28,
31,
184,
228,
213,
139,
240,
130,
56,
181,
225,
54,
152,
207,
6,
52,
227,
25,
177,
164,
114,
111,
194,
107,
83,
25,
224,
198,
156,
99,
54,
52,
198,
124,
38,
183,
21,
241,
158,
12,
120,
175,
198,
51,
99,
194,
31,
21,
227,
147,
126,
16,
91,
138,
248,
207,
131,
246,
60,
87,
240,
135,
25,
177,
226,
212,
112,
155,
198,
14,
124,
155,
221,
70,
28,
95,
182,
120,
241,
135,
201,
189,
212,
54,
115,
230,
222,
142,
19,
120,
193,
207,
147,
123,
168,
195,
139,
246,
207,
30,
48,
249,
55,
186,
134,
207,
155,
90,
39,
194,
111,
24,
60,
150,
207,
155,
122,
48,
226,
253,
185,
45,
199,
140,
57,
243,
111,
67,
114,
91,
62,
109,
232,
225,
53,
156,
114,
111,
131,
23,
199,
139,
81,
193,
196,
185,
60,
28,
218,
208,
101,
206,
15,
71,
227,
171,
91,
74,
147,
84,
57,
53,
234,
225,
165,
80,
228,
214,
139,
24,
203,
140,
29,
174,
202,
202,
45,
230,
177,
85,
118,
93,
92,
217,
205,
109,
87,
100,
90,
202,
31,
140,
29,
174,
202,
202,
45,
230,
181,
85,
118,
93,
92,
217,
205,
109,
87,
100,
90,
202,
31,
140,
29,
174,
202,
202,
45,
230,
181,
85,
118,
86,
115,
89,
209,
199,
6,
124,
218,
234,
90,
133,
33,
14,
80,
116,
70,
201,
90,
33,
209,
226,
151,
7,
3,
45,
90,
139,
12,
135,
38,
188,
224,
244,
126,
197,
74,
209,
14,
79,
19,
238,
57,
53,
214,
139,
24,
184,
228,
215,
156,
30,
143,
216,
167,
180,
67,
147,
196,
251,
142,
77,
117,
162,
198,
46,
57,
65,
209,
81,
194,
15,
23,
252,
154,
218,
128
};


const flash TMelody s_melody = {
s_melody_stream

};


-------------
[top]
mit Posted: 21 Jul 2018, 10:17 AM
Avatar
yeah whatever

Admin
Posts: 551
Joined: 4-May 16
OK. It printed 'paste from MidiToC program:' so python is working.

If you look at the python source code it is reading from sys.stdin. This is very much a linux / POSIX way of doing things and I don't know how it's implemented when python is run in a windows command line. I sometimes run python in a MINGW shell when using it on windows which may or may not solve that problem.

What you could do instead is edit the python file to read from a filename, rather than pasting the data in. The normal way of reading a file line-by-line in python is something like:

with open("songfile.h") as infile:
for line in infile:
#do something with the line here


So you'd need to edit the two places where it reads from stdin. You might also want to change the location it's outputting the file to (currently '../songs')

I just noticed another thing. The python file is looking for the start of the data at 's_melody_events', but the code that you pasted has the start of the data at 's_melody_stream' - that would certainly stop it from working.

-------------
[top]
DAVID Posted: 21 Jul 2018, 11:33 AM
Avatar
I love mcus

Member
Posts: 237
Joined: 10-September 17
so after digging in the py file i realize that the variable data = '' is use for reading the info so since its value its 0 there is no data on the created file

-------------
[top]
peterparker Posted: 4 Sep 2018, 04:55 PM
Avatar


Member
Posts: 1
Joined: 4-September 18
It is going to make the work where you will going to have the latest language to be practice by the user that is python which is very much easy to adapt the concepts where you will be getting the program done easily so netgear tech support will guide you to provide the information regarding the particular part where it is going to make it done after to make them understand the basic part .

Last edit by mit at 5 Sep 2018, 07:35 AM

-------------
[top]
brayand Posted: 24 Sep 2018, 09:09 PM
Avatar


Member
Posts: 1
Joined: 24-September 18
Spam

Last edit by mit at 24 Sep 2018, 09:10 PM

-------------
[top]

Sign in to post a reply.