Skip to content

Commit 355f13e

Browse files
Added Maven files from ThibaudJeannin/MurphyStudio
1 parent 75912db commit 355f13e

33 files changed

+4026
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Murphy Studio
2+
<p align="center">
3+
<img src="src/main/resources/icon.png" align="center"/>
4+
</p>
5+
6+
7+
## Participation
8+
Wanna participate? Don't hesitate to ask us questions !

pom.xml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>murphy-studio</groupId>
8+
<artifactId>murphy-studio-app</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<groupId>org.apache.maven.plugins</groupId>
15+
<artifactId>maven-compiler-plugin</artifactId>
16+
<version>3.7.0</version>
17+
<configuration>
18+
<source>1.8</source>
19+
<target>1.8</target>
20+
</configuration>
21+
</plugin>
22+
<plugin>
23+
<groupId>com.zenjava</groupId>
24+
<artifactId>javafx-maven-plugin</artifactId>
25+
<version>8.6.0</version>
26+
<configuration>
27+
<mainClass>murphystudio.application.Main</mainClass>
28+
</configuration>
29+
<executions>
30+
<execution>
31+
<id>create-jfxjar</id>
32+
<phase>package</phase>
33+
<goals>
34+
<goal>build-jar</goal>
35+
</goals>
36+
</execution>
37+
</executions>
38+
</plugin>
39+
</plugins>
40+
</build>
41+
42+
<dependencyManagement>
43+
<dependencies>
44+
<dependency>
45+
<groupId>com.oracle</groupId>
46+
<artifactId>javafx</artifactId>
47+
<version>2.2</version>
48+
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
49+
<scope>system</scope>
50+
</dependency>
51+
</dependencies>
52+
</dependencyManagement>
53+
54+
55+
</project>

src/main/java/META-INF/MANIFEST.MF

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Main-Class: murphystudio.application.Main
3+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package murphystudio.application;
2+
3+
import javafx.application.Application;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.geometry.Rectangle2D;
6+
import javafx.scene.Parent;
7+
import javafx.scene.Scene;
8+
import javafx.scene.image.Image;
9+
import javafx.stage.Screen;
10+
import javafx.stage.Stage;
11+
import murphystudio.controllers.MainController;
12+
13+
public class Main extends Application {
14+
15+
private static Stage primaryStage;
16+
17+
@Override
18+
public void start(Stage primaryStage) throws Exception{
19+
setPrimaryStage(primaryStage);
20+
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/views/main_layout.fxml"));
21+
Parent root = fxmlLoader.load();
22+
23+
Rectangle2D bounds = Screen.getPrimary().getBounds();
24+
25+
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png")));
26+
27+
MainController mainController = fxmlLoader.getController();
28+
mainController.setLightTheme();
29+
30+
Scene scene = new Scene(root);
31+
primaryStage.setTitle("Murphy Studio");
32+
primaryStage.setScene(scene);
33+
primaryStage.setMinWidth(root.minWidth(-1));
34+
primaryStage.setMinHeight(root.minHeight(-1) + 50);
35+
primaryStage.setHeight(root.prefHeight(-1));
36+
primaryStage.setWidth(root.prefWidth(-1));
37+
primaryStage.setX((bounds.getWidth() - primaryStage.getWidth()) / 2);
38+
primaryStage.setY((bounds.getHeight() - primaryStage.getHeight()) / 4);
39+
primaryStage.show();
40+
41+
42+
primaryStage.setOnCloseRequest(windowEvent -> {
43+
mainController.exit();
44+
System.exit(0);
45+
});
46+
47+
scene.setOnKeyPressed(ke -> mainController.setKeyPressed(ke.getCode()) );
48+
}
49+
50+
51+
52+
public static Stage getPrimaryStage(){
53+
return Main.primaryStage;
54+
}
55+
56+
private void setPrimaryStage(Stage p){
57+
primaryStage = p;
58+
}
59+
60+
61+
public static void main(String[] args) {
62+
launch(args);
63+
}
64+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package murphystudio.controllers;
2+
3+
import javafx.scene.control.Hyperlink;
4+
5+
import java.io.IOException;
6+
import java.net.URL;
7+
import java.util.ResourceBundle;
8+
9+
public class AboutController extends Controller {
10+
11+
public Hyperlink link_github;
12+
13+
@Override
14+
public void initialize(URL location, ResourceBundle resources)
15+
{
16+
link_github.setOnAction(e -> {
17+
try {
18+
new ProcessBuilder("x-www-browser", "https://github.com/Yarhi/Murphy_Studio").start();
19+
} catch (IOException e1) {
20+
e1.printStackTrace();
21+
}
22+
});
23+
}
24+
}
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
package murphystudio.controllers;
2+
3+
import javafx.collections.FXCollections;
4+
import javafx.collections.ObservableList;
5+
import javafx.fxml.Initializable;
6+
import javafx.scene.control.*;
7+
import javafx.scene.layout.BorderPane;
8+
import javafx.scene.layout.Pane;
9+
import murphystudio.models.MainModel;
10+
import murphystudio.objects.Accord;
11+
import murphystudio.objects.Tile;
12+
13+
import java.lang.reflect.InvocationTargetException;
14+
import java.lang.reflect.Method;
15+
import java.net.URL;
16+
import java.util.LinkedHashMap;
17+
import java.util.Map;
18+
import java.util.ResourceBundle;
19+
20+
public class ChordMakerController extends Controller implements Initializable {
21+
22+
public Button playChordButton;
23+
public Button saveChordButton;
24+
25+
public Label chordNameLabel;
26+
27+
public RadioButton doRadio,doDRadio, reRadio,reDRadio, miRadio, faRadio, faDRadio, solRadio, solDRadio, laRadio, laDRadio, siRadio ;
28+
public BorderPane chordMakerPane;
29+
private ToggleGroup noteChordGroup = new ToggleGroup();
30+
31+
private Boolean isSeventh = false, isFifth = false, isMinor = false;
32+
33+
private LinkedHashMap<String, Method> listToFunc;
34+
public ListView<String> chordListView;
35+
private ObservableList<String> items;
36+
37+
private MainModel model;
38+
39+
// 0 : Not / 1 : In function / 2 : Function finished
40+
private int printFromTile = 0;
41+
42+
@Override
43+
public void initialize(URL location, ResourceBundle resources) {
44+
listToFunc = new LinkedHashMap<>();
45+
46+
doRadio.setToggleGroup(noteChordGroup);
47+
doDRadio.setToggleGroup(noteChordGroup);
48+
reRadio.setToggleGroup(noteChordGroup);
49+
reDRadio.setToggleGroup(noteChordGroup);
50+
miRadio.setToggleGroup(noteChordGroup);
51+
faRadio.setToggleGroup(noteChordGroup);
52+
faDRadio.setToggleGroup(noteChordGroup);
53+
solRadio.setToggleGroup(noteChordGroup);
54+
solDRadio.setToggleGroup(noteChordGroup);
55+
laRadio.setToggleGroup(noteChordGroup);
56+
laDRadio.setToggleGroup(noteChordGroup);
57+
siRadio.setToggleGroup(noteChordGroup);
58+
59+
doRadio.fire();
60+
61+
try {
62+
listToFunc.put(("Minor"), Accord.class.getMethod("setMinor"));
63+
listToFunc.put(("Major"), Accord.class.getMethod("setMajor"));
64+
listToFunc.put(("Dominant Seventh"), Accord.class.getMethod("setDominantSeven"));
65+
listToFunc.put(("Minor Seventh"), Accord.class.getMethod("setMinorSeventh"));
66+
listToFunc.put(("Major Seventh"), Accord.class.getMethod("setMajorSeventh"));
67+
listToFunc.put(("Dominant Seventh with Flattened fifth"), Accord.class.getMethod("setDominantSeventhFlattenedFifth"));
68+
listToFunc.put(("Dominant Seventh with Sharp fifth"), Accord.class.getMethod("setDominantSeventhSharpedFifth"));
69+
listToFunc.put(("Sixth"), Accord.class.getMethod("setSixth"));
70+
listToFunc.put(("Minor sixth"), Accord.class.getMethod("setMinorSixth"));
71+
listToFunc.put(("Minor ninth"), Accord.class.getMethod("setMinorNinth"));
72+
listToFunc.put(("Major ninth"), Accord.class.getMethod("setMajorNinth"));
73+
listToFunc.put(("Diminished"), Accord.class.getMethod("setDiminished"));
74+
listToFunc.put(("Diminished seventh"), Accord.class.getMethod("setDiminishedSeventh"));
75+
listToFunc.put(("Augmented"), Accord.class.getMethod("setAugmented"));
76+
listToFunc.put(("Suspended fourth"), Accord.class.getMethod("setSuspendedFourth"));
77+
listToFunc.put(("Suspended second"), Accord.class.getMethod("setSuspendedSecond"));
78+
} catch (NoSuchMethodException e) {
79+
e.printStackTrace();
80+
}
81+
this.items = FXCollections.observableArrayList();
82+
83+
for(Map.Entry <String, Method> entry : listToFunc.entrySet())
84+
items.add(entry.getKey());
85+
86+
chordListView.setItems(items);
87+
chordListView.getSelectionModel().select(1);
88+
89+
chordListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
90+
if ( newValue == null || printFromTile == 1 ) return;
91+
92+
try {
93+
listToFunc.get(newValue).invoke(model.selectedChord);
94+
updtInfos();
95+
} catch (IllegalAccessException | InvocationTargetException e) {
96+
e.printStackTrace();
97+
}
98+
});
99+
100+
noteChordGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
101+
if ( newValue == null ) return;
102+
103+
Method lastFunction = model.selectedChord.getMethodCalled();
104+
105+
if (newValue == doRadio ) model.selectedChord = new Accord(60, isMinor, isFifth, isSeventh);
106+
if (newValue == doDRadio ) model.selectedChord = new Accord(61, isMinor, isFifth, isSeventh);
107+
if (newValue == reRadio ) model.selectedChord = new Accord(62, isMinor, isFifth, isSeventh);
108+
if (newValue == reDRadio ) model.selectedChord = new Accord(63, isMinor, isFifth, isSeventh);
109+
if (newValue == miRadio ) model.selectedChord = new Accord(64, isMinor, isFifth, isSeventh);
110+
if (newValue == faRadio ) model.selectedChord = new Accord(65, isMinor, isFifth, isSeventh);
111+
if (newValue == faDRadio ) model.selectedChord = new Accord(66, isMinor, isFifth, isSeventh);
112+
if (newValue == solRadio ) model.selectedChord = new Accord(67, isMinor, isFifth, isSeventh);
113+
if (newValue == solDRadio) model.selectedChord = new Accord(68, isMinor, isFifth, isSeventh);
114+
if (newValue == laRadio ) model.selectedChord = new Accord(69, isMinor, isFifth, isSeventh);
115+
if (newValue == laDRadio ) model.selectedChord = new Accord(70, isMinor, isFifth, isSeventh);
116+
if (newValue == siRadio ) model.selectedChord = new Accord(71, isMinor, isFifth, isSeventh);
117+
118+
119+
try {
120+
Accord.class.getMethod(lastFunction.getName()).invoke(model.selectedChord);
121+
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
122+
e.printStackTrace();
123+
}
124+
125+
updtInfos();
126+
});
127+
128+
playChordButton.setOnMouseClicked(event -> {
129+
Accord ch = ( printFromTile == 2 ) ? model.selectedTile.accord : model.selectedChord;
130+
for (int i = 0; i < ch.getNotes().size(); i++)
131+
this.model.midiInterface.playNote(ch.getNotes().get(i));
132+
});
133+
134+
saveChordButton.setOnMouseClicked(event -> saveChord());
135+
136+
}
137+
138+
private void updtInfos()
139+
{
140+
if ( printFromTile == 2 ) printFromTile = 0;
141+
chordNameLabel.setText(model.selectedChord.getName());
142+
this.model.chordSorterController.resetKeys();
143+
this.model.chordSorterController.colorizeKeys();
144+
}
145+
146+
private void saveChord()
147+
{
148+
if ( model != null && model.selectedChord != null && printFromTile != 1 )
149+
model.chordSorterController.changeSelectedTileChord(model.selectedChord);
150+
151+
}
152+
153+
154+
private String getChordNameByMethod(Accord accord)
155+
{
156+
if ( accord.getMethodCalled() == null ) return null;
157+
158+
String name = null;
159+
for ( Map.Entry<String, Method> entry : listToFunc.entrySet() )
160+
if (entry.getValue().getName().equals(accord.getMethodCalled().getName())) name = entry.getKey();
161+
162+
return name;
163+
}
164+
165+
private void fireRadio(Accord ch)
166+
{
167+
switch (ch.getDominantName()) {
168+
case "A" : laRadio.fire(); break;
169+
case "A#" : laDRadio.fire(); break;
170+
case "B" : siRadio.fire(); break;
171+
case "C" : doRadio.fire(); break;
172+
case "C#" : doDRadio.fire(); break;
173+
case "D" : reRadio.fire(); break;
174+
case "D#" : reDRadio.fire(); break;
175+
case "E" : miRadio.fire(); break;
176+
case "F" : faRadio.fire(); break;
177+
case "F#" : faDRadio.fire(); break;
178+
case "G" : solRadio.fire(); break;
179+
case "G#" : solDRadio.fire(); break;
180+
}
181+
}
182+
183+
public void updateFromTile(Tile tile)
184+
{
185+
printFromTile = 1;
186+
187+
Accord ch = tile.accord;
188+
chordListView.getSelectionModel().select(getChordNameByMethod(model.selectedTile.accord));
189+
fireRadio(ch);
190+
191+
chordNameLabel.setText(ch.getName());
192+
for (Pane aNotesPane : this.model.chordSorterController.notesPane) aNotesPane.setStyle(null);
193+
for (int note : ch.getNotes()) {
194+
int notePaneIndex = note - 60;
195+
this.model.chordSorterController.notesPane[notePaneIndex].setStyle("-fx-background-color: red");
196+
}
197+
198+
printFromTile = 2;
199+
}
200+
201+
public void setModel(MainModel model) {
202+
this.model = model;
203+
204+
model.selectedChord = new Accord(60, false, false, false);
205+
model.selectedChord.setMajor();
206+
updtInfos();
207+
208+
}
209+
}

0 commit comments

Comments
 (0)