Skip to content

Commit

Permalink
organize main class
Browse files Browse the repository at this point in the history
  • Loading branch information
vonqo committed Sep 1, 2021
1 parent 14dd26e commit fb4584e
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 51 deletions.
61 changes: 38 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# <img height="42px" src="https://github.com/punkowl/gestalt/blob/master/public/gestalt-logo.png" /> & <img height="42px" src="https://github.com/punkowl/gestalt/blob/master/public/cnc-logo.png" />
# <img height="42px" src="https://github.com/punkowl/gestalt/blob/master/public/gestalt-logo.png" /> <img height="42px" src="https://github.com/punkowl/gestalt/blob/master/public/cnc-logo.png" />


[![Codacy Badge][codacy-badge]][codacy]
[![Gitter][gitter-badge]][gitter]
[![HitCount][hit-badge]][hit]
[![Shitcoded][ulaanbaatar-badge]][ub-wiki]

Definition of **gestalt**: "*something that is made of many parts and yet is somehow more than or different from the combination of its parts*"

This is an open source repository of creative coding integrations and playground. Some visual ouputs are posted on following pages.

* Facebook page: [Color Note and Code](https://www.facebook.com/colornotecode/)
* Facebook page: [Color Note Code](https://www.facebook.com/colornotecode/)
* Instagram: [@colornotecode](https://www.instagram.com/colornotecode/)
* YouTube: [vonqo](https://www.youtube.com/channel/UCGmwCteDtjSBGco4qqs1QIQ/)

Expand All @@ -30,10 +29,10 @@ This is an open source repository of creative coding integrations and playground
* **hqz** - Used in orchestrator. Forked from [scanlime](https://github.com/scanlime)/[zenphoton](https://github.com/scanlime/zenphoton)
* **a1_restorer** - Image defect fixing, enhance greyscale

* **sketches** - Processing sketches
* **study_materials** - Project related study materials.
* **sketches** - Processing sketches.
* **study_materials** - Project related study material list.

## Install and use
## Installation
Execute ```install.sh```. Installation script is not maintained. If things gone wrong, screw this script and go manual.

### Manual installation
Expand All @@ -48,32 +47,48 @@ And install these third party tools:
* [experimental] ~~[Neural Style torch implementation](https://github.com/jcjohnson/neural-style) + [cuDNN](https://developer.nvidia.com/cudnn)~~


### How to use
## Usage
1. Edit ```modules/orchestrator/config.json``` to setup your paths.
* You can ignore ```neuralStyle``` section unless you've installed it.
2. Edit and freestyle your ```src/.../Orchestrator.java```
```java
@LoadOrchestrator
public static void main(String args[]) {
Config.loadConfig();

renderCollection();
renderZenphoton();
renderZenphotonFrames();
renderVanillaMoodbars();
2. Edit and freestyle your ```config.json```
```json
{
"system": {
"moodbarExecuteable": "moodbar",
"hqzExecutable": "~/gestalt/modules/zenphoton/hqz/hqz",
"ffmpegExecutable": "ffmpeg",
"resourceDir": "~/Desktop/",
"neuralStyle": {
"executable": "~/neural-style.lua",
"styleDir": "~/style_img/",
"contentDir": "~/content_img/"
}
},
"param": {
"exportType": "VANILLA",
"audioFile": ["audio1", "audio2", "audio3"],
"displayText": ["title1", "title2", "title3"],
"hasBanner": true,
"ray": 250000,
"extraDataFile": "drawExported.json",
"videoExport": {
"isVideoExport": false,
"usableCore": 12,
"startFrame": 0,
"endFrame": 4000
}
}
}
```
3. Build it with [Maven](https://maven.apache.org/).
4. Run

## Copyright & License
Copyright (c) 2019 Enkh-Amar.G - Released under the [Mozilla Public License Version 2.0](LICENSE)
## License
Enkh-Amar. G (vonqo). Released under the [Mozilla Public License Version 2.0](LICENSE)

[gestalt-logo]: https://github.com/lupino22/gestalt/blob/master/public/logo.png
[codacy-badge]: https://api.codacy.com/project/badge/Grade/5085d2cd13a245a0af21f85f48ae23a9
[codacy]: https://www.codacy.com/app/lupino22/gestalt?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=lupino22/gestalt&amp;utm_campaign=Badge_Grade
[hit-badge]: http://hits.dwyl.io/vonqo/gestalt.svg
[hit]: http://hits.dwyl.io/vonqo/gestalt
[codacy-badge]: https://app.codacy.com/project/badge/Grade/8d438e4c49964773b4668d381c478bfc
[codacy]: https://www.codacy.com/gh/PunkOwl/gestalt/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=PunkOwl/gestalt&amp;utm_campaign=Badge_Grade
[gitter-badge]: https://badges.gitter.im/punkowl-gestalt/community.svg
[gitter]: https://gitter.im/punkowl-gestalt/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
[ulaanbaatar-badge]: https://img.shields.io/badge/shitcoded%20in-%F0%9F%87%B2%F0%9F%87%B3ulaanbaatar-brightgreen.svg
Expand Down
4 changes: 2 additions & 2 deletions modules/orchestrator/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"param": {
"exportType": "VANILLA",
"audioFile": [""],
"displayText": [""],
"audioFile": ["etogg"],
"displayText": ["dsfdsa"],
"hasBanner": true,
"ray": 250000,
"extraDataFile": "dafuq.json",
Expand Down
142 changes: 116 additions & 26 deletions modules/orchestrator/src/main/java/mn/von/gestalt/Orchestrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,20 @@ public static void main(String args[]) {

} else if(type.equals(ExportTypes.BUBBLE_BAR_2DRT.name())) {


renderBubbleBarZenphoton(paramDto);

} else if(type.equals(ExportTypes.WHIRLWIND_2DRT.name())) {


renderWhirlwindZenphoton(paramDto);

} else if(type.equals(ExportTypes.DRAWING_2DRT.name())) {

renderZenphotonDrawing();
renderZenphotonDrawing(paramDto.getExtraDataFile(), paramDto.getRay());

} else if(type.equals(ExportTypes.CARDIAC.name())) {

renderCardiacZenphoton(paramDto);

}
}

Expand Down Expand Up @@ -215,7 +217,7 @@ private static void renderNoise() {

/* ============================================================================================ */
/* ============================================================================================ */
private static void renderZenphotonDrawing() {
private static void renderZenphotonDrawing(String extraDataFile, int ray) {
String songname = "turing";
String testPath = Config.RESOURCE_DIR;
String pathMp3 = testPath+songname+".mp3";
Expand All @@ -234,7 +236,7 @@ private static void renderZenphotonDrawing() {
try {
ArrayList<Color> moodbar = MoodbarAdapter.buildMoodbar(testPath+songname+".mp3",testPath+"/bar");

final String objectFile = Config.RESOURCE_DIR+"data_1133295"+".json";
final String objectFile = Config.RESOURCE_DIR + extraDataFile;
Gson gson = new Gson();
BufferedReader br = new BufferedReader(new FileReader(objectFile));
ArrayList<ArrayList<Integer>> objects = gson.fromJson(br, new TypeToken<ArrayList<ArrayList<Integer>>>(){}.getType());
Expand All @@ -253,7 +255,7 @@ private static void renderZenphotonDrawing() {

LunarTearHqz hqz = new LunarTearHqz();
File outputFile = new File(Config.RESOURCE_DIR+"/"+songname+"_drawing."+ Config.OUTPUT_IMAGE_FORMAT);
hqz.buildDrawing(800*2, 670*2, zObjects, moodbar, 20000, outputFile);
hqz.buildDrawing(800*2, 670*2, zObjects, moodbar, ray, outputFile);

} catch (FileNotFoundException e) {
e.printStackTrace();
Expand All @@ -264,13 +266,12 @@ private static void renderZenphotonDrawing() {

/* ============================================================================================ */
/* ============================================================================================ */
private static void renderZenphoton() {
// String songname = "fur_elise";
String songname = "laura";
String displayText = "renderZenphoton";
String testPath = Config.RESOURCE_DIR;
String pathMp3 = testPath+songname+".mp3";
String pathWav = testPath+songname+".wav";
private static void renderBubbleBarZenphoton(ParamDto param) {
String path = Config.RESOURCE_DIR;

String songname = param.getAudioFile().get(0);
String pathMp3 = path + songname + ".mp3";
String pathWav = path + songname + ".wav";
double audioDuration = 0;

try {
Expand All @@ -283,27 +284,116 @@ private static void renderZenphoton() {
}

try {
ArrayList<Color> moodbar = MoodbarAdapter.buildMoodbar(testPath+songname+".mp3",testPath+"/bar");
ArrayList<Color> moodbar = MoodbarAdapter.buildMoodbar(path+songname+".mp3",path+"/bar");
Spectrumizer spectrumizer = new Spectrumizer(pathWav, 4096);
spectrumizer.applyMoodbar(moodbar);
spectrumizer.build();

int ray = 2500000;
// int ray = 5000;
int ray = param.getRay();
File outputFile = new File(Config.RESOURCE_DIR+"/"+songname+"_"+ray+"."+ Config.OUTPUT_IMAGE_FORMAT);
LunarTearHqz hqz = new LunarTearHqz();
// hqz.build(LunarTearHqz.Types.BUBBLE2_PRINTABLE, moodbar, spectrumizer.getDATA(), ray, outputFile, audioDuration);

hqz.build(LunarTearHqz.Types.BUBBLE2_PRINTABLE, moodbar, spectrumizer.getDATA(), ray, outputFile, audioDuration);

// BufferedImage img = ImageIO.read(outputFile);
// ImageSupporter.setBackgroundColor(Color.BLACK);
// ImageSupporter.setFontColor(Color.WHITE);
// ImageSupporter.setFontSize(32);
// ImageSupporter.setFontName("Roboto Mono");
// ImageIO.write(
// ImageSupporter.addTitle(img, displayText), Config.OUTPUT_IMAGE_FORMAT, outputFile
// );
BufferedImage img = ImageIO.read(outputFile);
ImageSupporter.setBackgroundColor(Color.BLACK);
ImageSupporter.setFontColor(Color.WHITE);
ImageSupporter.setFontSize(32);
ImageSupporter.setFontName("Roboto Mono");
ImageIO.write(
ImageSupporter.addTitleOver(img, param.getDisplayText().get(0), 10, 10),
Config.OUTPUT_IMAGE_FORMAT,
outputFile
);
} catch (Exception e) {
e.printStackTrace();
}
}

/* ============================================================================================ */
/* ============================================================================================ */
private static void renderCardiacZenphoton(ParamDto param) {
String path = Config.RESOURCE_DIR;

String songname = param.getAudioFile().get(0);
String pathMp3 = path + songname + ".mp3";
String pathWav = path + songname + ".wav";
double audioDuration = 0;

try {
AudioUtils.mp3ToWav(new File(pathMp3), pathWav);
audioDuration = AudioUtils.getDuration(pathWav);
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

try {
ArrayList<Color> moodbar = MoodbarAdapter.buildMoodbar(path+songname+".mp3",path+"/bar");
Spectrumizer spectrumizer = new Spectrumizer(pathWav, 4096);
spectrumizer.applyMoodbar(moodbar);
spectrumizer.build();

int ray = param.getRay();
File outputFile = new File(Config.RESOURCE_DIR+"/"+songname+"_"+ray+"."+ Config.OUTPUT_IMAGE_FORMAT);
LunarTearHqz hqz = new LunarTearHqz();
hqz.build(LunarTearHqz.Types.CARDIAC, moodbar, spectrumizer.getDATA(), ray, outputFile, audioDuration);

BufferedImage img = ImageIO.read(outputFile);
ImageSupporter.setBackgroundColor(Color.BLACK);
ImageSupporter.setFontColor(Color.WHITE);
ImageSupporter.setFontSize(32);
ImageSupporter.setFontName("Roboto Mono");
ImageIO.write(
ImageSupporter.addTitle(img, param.getDisplayText().get(0)),
Config.OUTPUT_IMAGE_FORMAT,
outputFile
);
} catch (Exception e) {
e.printStackTrace();
}
}

/* ============================================================================================ */
/* ============================================================================================ */
private static void renderWhirlwindZenphoton(ParamDto param) {
String path = Config.RESOURCE_DIR;

String songname = param.getAudioFile().get(0);
String pathMp3 = path + songname + ".mp3";
String pathWav = path + songname + ".wav";
double audioDuration = 0;

try {
AudioUtils.mp3ToWav(new File(pathMp3), pathWav);
audioDuration = AudioUtils.getDuration(pathWav);
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

try {
ArrayList<Color> moodbar = MoodbarAdapter.buildMoodbar(path+songname+".mp3",path+"/bar");
Spectrumizer spectrumizer = new Spectrumizer(pathWav, 4096);
spectrumizer.applyMoodbar(moodbar);
spectrumizer.build();

int ray = param.getRay();
File outputFile = new File(Config.RESOURCE_DIR+"/"+songname+"_"+ray+"."+ Config.OUTPUT_IMAGE_FORMAT);
LunarTearHqz hqz = new LunarTearHqz();
hqz.build(LunarTearHqz.Types.TORNADO, moodbar, spectrumizer.getDATA(), ray, outputFile, audioDuration);

BufferedImage img = ImageIO.read(outputFile);
ImageSupporter.setBackgroundColor(Color.BLACK);
ImageSupporter.setFontColor(Color.WHITE);
ImageSupporter.setFontSize(32);
ImageSupporter.setFontName("Roboto Mono");
ImageIO.write(
ImageSupporter.addTitle(img, param.getDisplayText().get(0)),
Config.OUTPUT_IMAGE_FORMAT,
outputFile
);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ public static BufferedImage addTitle (BufferedImage image, String title) {
return canvas;
}

public static BufferedImage addTitleOver(BufferedImage image, String title, int paddingTop, int paddingLeft) {
BufferedImage canvas = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D ctx2D = canvas.createGraphics();
ctx2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
ctx2D.setPaint (ImageSupporter.backgroundColor);
ctx2D.fillRect(0,0,canvas.getWidth(),canvas.getHeight());
ctx2D.setFont(new Font(fontName, Font.PLAIN, fontSize));
ctx2D.setColor(ImageSupporter.fontColor);
ctx2D.drawString(title, paddingTop, paddingLeft);
ctx2D.drawImage(image, 0 , 0, null);
return canvas;
}

public static BufferedImage addMark(BufferedImage image, String text, int topPadding) throws IOException {
BufferedImage canvas = new BufferedImage(image.getWidth(), image.getHeight()+50+topPadding, BufferedImage.TYPE_INT_ARGB);
BufferedImage logo = ImageIO.read(new File("logo_smoll.png"));
Expand Down

0 comments on commit fb4584e

Please sign in to comment.