gpt4 book ai didi

shell - 从shell使用Processing-3.2.2

转载 作者:行者123 更新时间:2023-12-02 23:07:25 25 4
gpt4 key购买 nike

伙计们,我正在研究音频可视化,并在pde中成功运行了文件。该代码采用“input.mp3”,然后导出.mp4文件。是否可以通过终端(.sh)使用它?我的意思是写一些命令来执行程序。喜欢:

processing-3.2.2 filename.pde input.mp3

并生成该input.mp3的视频。这是我的代码:
import ddf.minim.*;
import ddf.minim.analysis.*;
import com.hamoid.*;

Minim minim;
AudioPlayer player;
AudioMetaData meta;
BeatDetect beat;
VideoExport videoExport;
int r = 200;
float rad = 70;
void setup()
{
size(600, 600);
//size(600, 400);
minim = new Minim(this);
player = minim.loadFile("son_final.mp3");
meta = player.getMetaData();
beat = new BeatDetect();
videoExport = new VideoExport(this, "basic.mp4");
player.loop();
//player.play();
background(-1);
noCursor();
}

void draw()
{
float t = map(mouseX, 0, width, 0, 1);
beat.detect(player.mix);
fill(#1A1F18, 20);
noStroke();
rect(0, 0, width, height);
translate(width/2, height/2);
noFill();
fill(-1, 10);
if (beat.isOnset()) rad = rad*0.9;
else rad = 70;
ellipse(0, 0, 2*rad, 2*rad);
stroke(-1, 50);
int bsize = player.bufferSize();
for (int i = 0; i < bsize - 1; i+=5)
{
float x = (r)*cos(i*2*PI/bsize);
float y = (r)*sin(i*2*PI/bsize);
float x2 = (r + player.left.get(i)*100)*cos(i*2*PI/bsize);
float y2 = (r + player.left.get(i)*100)*sin(i*2*PI/bsize);
line(x, y, x2, y2);
}
beginShape();
noFill();
stroke(-1, 50);
for (int i = 0; i < bsize; i+=30)
{
float x2 = (r + player.left.get(i)*100)*cos(i*2*PI/bsize);
float y2 = (r + player.left.get(i)*100)*sin(i*2*PI/bsize);
vertex(x2, y2);
pushStyle();
stroke(-1);
strokeWeight(2);
point(x2, y2);
popStyle();
}
endShape();
if (flag) showMeta();
videoExport.saveFrame();
}



void showMeta() {
int time = meta.length();
textSize(50);
textAlign(CENTER);
text( (int)(time/1000-millis()/1000)/60 + ":"+ (time/1000-millis()/1000)%60, -7, 21);
}

boolean flag =false;
void mousePressed() {
if (dist(mouseX, mouseY, width/2, height/2)<150) flag =!flag;
}

void keyPressed() {
if(key==' ')exit();
if(key=='s')saveFrame("###.jpeg");
}

最佳答案

您不能从命令行或脚本运行.pde文件。

但是您可以将.pde文件转换为Java应用程序,然后像运行任何其他Java应用程序一样运行该Java应用程序。

第一步,从“处理”编辑器中,转到File > Export Application...,它会打开“导出选项”窗口。在此处设置您的选项(可能会稍作调整以查看每个选项的作用),然后单击Export按钮。

这会将应用程序导出到您的草图目录。该应用程序为您提供了各种.java.jar文件,您可以将它们用作Java应用程序。

从那里开始,只需像运行其他任何.jar文件一样运行.jar文件即可。

关于shell - 从shell使用Processing-3.2.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40438945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com