-
Notifications
You must be signed in to change notification settings - Fork 2
/
SongPlay11.pde
171 lines (155 loc) · 4.42 KB
/
SongPlay11.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/104161*@* */
/* !do not delete the line above, required for linking your tweak if you re-upload */
//
// best version, now with states and a small help (F1)
// also with MP3 image when available.
//
// *****************************************************
// config:
// make your changes here
// enter your music path here
// pathGlobalDefault: set path or use "" to use data path of the sketch
//final String pathGlobalDefault = "D://Musik//";
//final String pathGlobalHome = "D://Musik//Adele//";
final String pathGlobalDefault = "C:\\Users\\Ernesto Guevara\\Music\\";
final String pathGlobalHome = "C://Users//Ernesto Guevara//Music//";
// show song list / show information of one song
boolean showSongList = false; // list or meta
boolean showFFT = true; // show fft yes/no
// end of config
// *****************************************************
//import
import ddf.minim.*;
import ddf.minim.analysis.*;
import java.io.*;
import java.awt.image.BufferedImage;
//
//
import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
// this File "pathGlobal" gets it path from "pathGlobalDefault" :
File pathGlobal;
// to go back & forth in old / used paths
ArrayList<File> usedPaths = new ArrayList();
int usedPathsIndex;
//
// see
// http://code.compartmental.net/tools/minim/quickstart/
// http://code.compartmental.net/minim/javadoc/
//
// states
final int stateNormal =0; // play song
// this is the state for file manager / when no song is found in the
// folder:
final int stateFileManager =1; // dir exists but has no mp3
final int stateHelp =3; // show help
final int stateUndefined =-1; // state Undefined
final int stateDrives =4; // state Drives
int state = stateNormal; // current state
int formerState = stateUndefined; // when we go to the help screen,
// we want to return to the state we were before in
// (it's only one help screen for the whole program)
//
// song stuff
Minim minim;
AudioPlayer song;
AudioMetaData meta; // meta data of a song
int songLength = 0;
boolean paused = false;
FFT fft; // frequence display
PImage mp3Image; // show cover image from MP3
boolean showMp3Image = true;
//
// screen buttons
Button buttonPause;
Button buttonProgressFrame;
Button buttonProgressData;
Button buttonPrevious;
Button buttonNext;
Button buttonFolder;
Button buttonShowSongListOrOneSong;
Button buttonFolderUp;
Button buttonHome;
Button buttonPreviousFolder;
Button buttonNextFolder;
ArrayList<Button> buttonsList = new ArrayList();
// store time since last mouse moved - for tool tip text
int timeSinceLastMouseMoved=0;
//
// songs and Co.
String[] namesFiles; // songs in folder
int indexFile = 0; // index of current song in namesFiles
// folders and drives
String[] namesFolders;
int from;
int indexFolder;
boolean folderDoesExist=true;
String headline;
//
// Other vars
// background images
PImage img;
PImage imgForFileManager;
//
// status msg (a class)
ClassStatusMsg statusMsg = new ClassStatusMsg();
//
// ------------------------------------------------------------
//
void setup()
{
size(500, 500);
pathGlobal=new File (pathGlobalDefault);
usedPaths.add(pathGlobal);
usedPathsIndex=0;
minim = new Minim(this);
getFolder();
// define buttons
defineButtons();
getCurrentSong();
// get background images
img = loadImage("bkg.jpg");
imgForFileManager = loadImage("forfiles.jpg");
// store time since last mouse moved
timeSinceLastMouseMoved = millis();
}
//
void draw()
{
// mouse for tool tip text
if ((mouseX!=pmouseX) || (mouseY!=pmouseY)) {
// mouse has been moved:
// store time since last mouse moved
timeSinceLastMouseMoved = millis();
}
// states
switch (state) {
case stateNormal:
normalProgram ();
break;
case stateFileManager:
stateFileManagerFunction();
break;
case stateHelp:
showHelp();
break;
case stateDrives:
stateDrivesFunction();
break;
default:
println ("Missing state, error 111, tab Main");
exit();
break;
} // switch
//
} // func draw()
//