Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/media inhibitor cross fading #430

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/public/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"}
{"buildMajor":1,"buildMinor":125,"buildRevision":241,"buildTag":"dev","buildDate":"Fri May 31 2024","build":"1.125.241 dev"}
1 change: 1 addition & 0 deletions client/src/client/services/media/MediaManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
const channel = chls[i];
if (all) {
channel.fadeChannel(0, time, () => {
console.log('callback reached');

Check warning on line 89 in client/src/client/services/media/MediaManager.jsx

View workflow job for this annotation

GitHub Actions / build (20.*)

Unexpected console statement
this.mixer.removeChannel(channel);
});
matchedAndStopped = channel;
Expand Down
21 changes: 17 additions & 4 deletions client/src/client/services/media/objects/Channel.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import { getGlobalState } from '../../../../state/store';
import { debugLog } from '../../debugging/DebugService';

export class Channel {
constructor(channelName) {
constructor(channelName, originalVolume = 100) {
this.channelName = channelName;
this.channelVolume = 100;
this.channelVolume = originalVolume;
this.originalVolume = originalVolume;
this.sounds = [];
this.mixer = null;
this.targetAfterFade = 0;
this.isFading = false;
this.fadeTimer = [];
this.tags = new Map();
this.trackable = false;
this.prefferedFadeTime = 2;
}

getOriginalVolume() {
return this.originalVolume;
}

setPrefferedFadeTime(fadeTime) {
console.log('Setting preffered fade time to', fadeTime);

Check warning on line 23 in client/src/client/services/media/objects/Channel.jsx

View workflow job for this annotation

GitHub Actions / build (20.*)

Unexpected console statement
this.prefferedFadeTime = fadeTime;
}

getPrefferedFadeTime() {
return this.prefferedFadeTime || 2;
}

setTag(name) {
Expand Down Expand Up @@ -65,7 +79,6 @@

// is the fade time set to 0? then just set the volume, do callback and return
if (time === 0) {
debugLog('Fading channel', this.channelName, 'to', targetVolume, 'instantly');
this.setChannelVolume(targetVolume);
extraCallback();
return;
Expand Down
20 changes: 16 additions & 4 deletions client/src/client/services/media/objects/Mixer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,22 @@ export class Mixer {
}
});

if (score >= 1) {
channel.setMediaMuted(true);
} else {
channel.setMediaMuted(false);
const fade = channel.getPrefferedFadeTime() > 5;

if (score >= 1 && !channel.mutedByScore) {
channel.mutedByScore = true;
if (fade) {
channel.fadeChannel(0, channel.getPrefferedFadeTime());
} else {
channel.setChannelVolume(0);
}
} else if (score === 0 && channel.mutedByScore) {
channel.mutedByScore = false;
if (fade) {
channel.fadeChannel(channel.getOriginalVolume(), channel.getPrefferedFadeTime());
} else {
channel.setChannelVolume(channel.getOriginalVolume());
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export async function handleCreateMedia(data) {
MediaManager.destroySounds(id, false, true);

// register with metadata
const createdChannel = new Channel(id);
const createdChannel = new Channel(id, volume);
createdChannel.trackable = true;
createdChannel.setPrefferedFadeTime(fadeTime);
const createdMedia = new Sound();

createdChannel.addSound(createdMedia);
Expand Down
2 changes: 1 addition & 1 deletion client/src/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"}
{"buildMajor":1,"buildMinor":125,"buildRevision":241,"buildTag":"dev","buildDate":"Fri May 31 2024","build":"1.125.241 dev"}
8 changes: 4 additions & 4 deletions dev-resources/spawn-test-spigot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ cp dev-resources/ops.json test-server-spigot/

cd test-server-spigot
echo "Cleaning server..."
if [ ! -f ./spigot-1.20.2.jar ]; then
wget https://download.getbukkit.org/spigot/spigot-1.20.2.jar
if [ ! -f ./spigot-1.20.4.jar ]; then
wget https://download.getbukkit.org/spigot/spigot-1.20.4.jar
echo "eula=true" > eula.txt
chmod +x spigot-1.20.2.jar
chmod +x spigot-1.20.4.jar
fi

#export OA_ENVIRONMENT="DEVELOPMENT"
Expand All @@ -29,4 +29,4 @@ echo "Starting server.."
rm world/session.lock
rm world_the_end/session.lock
rm world_nether/session.lock
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar paper-1.20.6-49.jar nogui
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.20.4.jar nogui
6 changes: 0 additions & 6 deletions modules/vistas-server/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/bash/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1433"
BUILD_NUM="1438"
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Media getMediaForWorld(WorldRegionManager worldRegionManager) {
if (loop == null) loop = true;
Media media = worldRegionManager.getRegionMedia(source, volume, fadeTimeMs, loop);
media.setDoPickup(this.doSync);
media.setFadeTime(fadeTimeMs);
return media;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="1433"
BUILD_NUM="1438"
4 changes: 2 additions & 2 deletions plugin/src/main/resources/openaudiomc-build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD_VERSION="1433"
BUILD_COMMIT="e9dd7b36b9ce027c21f01124492be0a47231f1cb"
BUILD_VERSION="1438"
BUILD_COMMIT="b185ac1858bdbe73f0106928153783356d59ef1b"
BUILD_AUTHOR="Mats"
Loading