I want to make my music fade in and out between songs. So I must get the music's total duration.
How do I get an Ogg's duration?
I've researched and it seems you need Mpg123Decoder but it doesn't exist. What am I doing wrong?
UPDATE:
I tried this (it might be that I am doing something wrong with the external paths):
FileHandle list = Gdx.files.internal("./bin/sounds/music");
for (FileHandle files : list.list("ogg")) {
FileHandle f = Gdx.files.external(Game.EXTERNALPATH + "sounds/music/" + files.name());
if (!f.exists()) {
files.copyTo(f);
}
musicList.add(f);
musicListInternal.add(files);
}
So the paths are:
Nulled/sounds/music/Rainbows and Unicorns.ogg
Nulled/sounds/music/The Stage is Set.ogg
Nulled/sounds/music/Victory Theme (Faded).ogg
And
currentMusic = Gdx.audio.newMusic(musicListInternal.get(currentPlayingIndex));
mpgDecoder = new Mpg123Decoder(musicList.get(currentPlayingIndex));
totalDuration = mpgDecoder.getLength();
mpgDecoder.dispose();
currentMusic.play();
But It gives me an error:
LwjglGraphics: created OpenGL 3.2+ core profile context. This is experimental!
3 musics loaded!
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000126f1d30, pid=8116, tid=3668
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b15) (build 1.8.0_45-b15)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [gdx-audio64.dll+0x1d30]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\PhysiOS\Dropbox\Programming\workspace\nulled\desktop\hs_err_pid8116.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
AL lib: (EE) alc_cleanup: 1 device not closed
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:717] error: Encountered free format header, but failed to guess frame size.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:717] error: Encountered free format header, but failed to guess frame size.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:717] error: Encountered free format header, but failed to guess frame size.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 65688.
Note: Trying to resync...
Note: Skipped 757 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 66446.
Note: Trying to resync...
Note: Skipped 55 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 66502.
Note: Trying to resync...
Note: Skipped 32 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 66535.
Note: Trying to resync...
Note: Skipped 90 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 66626.
Note: Trying to resync...
Note: Skipped 939 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 67566.
Note: Trying to resync...
Note: Skipped 14 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1040] error: Giving up searching valid MPEG header after (over) 64K of junk.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:650] error: tried to decode obviously invalid header
Note: Illegal Audio-MPEG-Header 0x00000000 at offset 67581.
Note: Trying to resync...
Note: Skipped 1024 bytes in input.
[/var/lib/jenkins/workspace/libgdx/extensions/gdx-audio/jni/libmpg123/parse.c:1121] error: Giving up resync after 1024 bytes - your stream is not nice... (maybe increasing resync limit could help).
Trouble with mpg123: Failed to find valid MPEG data within limit on resync. (code 28)
UPDATE: Wrong decoder, used VorbisDecoder instead.
The Mpg123Decoder class comes with the audio extension ,unfortunately this extension is deprecated.Since it seems that the jars have been removed from the libgdx project extensions page and I couldn't find anything anywhere else on google, I uploaded a zip here, Its an old version but I believe it will work just fine with the new versions of libgdx.
To use it you need first to copy the music file from the application's folder to a location on the external memory
public static Mpg123Decoder getDecoder(String musicFile){
FileHandle file=Gdx.files.internal(musicFile);
FileHandle external=Gdx.files.external("myappexternalfolder/"+file.name());
if(!external.exists())file.copyTo(external); //copy the file to the external storage only if it doesnt exists yet
return new Mpg123Decoder(external);
}
public float getMusicFileLength(String musicFile){
return getDecoder(musicFile).getLength();
}
It returns a float, for example 10.5=>ten and a half seconds
Related
I am trying to train a yolov5 model, but I'm getting an exception error when I try to execute the training module. The error occurs after the model is loaded and when it tries to read the training images. Below is my code and an excerpt of the error. Any help would be appreciated.
!python train.py --img 640 --batch 16 --epochs 150 --data pollen_data.yaml --weights yolov5x.pt
Model summary: 567 layers, 86217814 parameters, 86217814 gradients, 204.2 GFLOPs
Transferred 739/745 items from yolov5x.pt
Scaled weight_decay = 0.0005
optimizer: SGD with parameter groups 123 weight (no decay), 126 weight, 126 bias
albumentations: version 1.0.3 required by YOLOv5, but version 0.1.12 is currently installed
Traceback (most recent call last):
File "/content/yolov5/utils/datasets.py", line 405, in __init__
t = t.read().strip().splitlines()
File "/usr/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train.py", line 643, in <module>
main(opt)
File "train.py", line 539, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 227, in train
prefix=colorstr('train: '), shuffle=True)
File "/content/yolov5/utils/datasets.py", line 110, in create_dataloader
prefix=prefix)
File "/content/yolov5/utils/datasets.py", line 415, in __init__
raise Exception(f'{prefix}Error loading data from {path}: {e}\nSee {HELP_URL}')
Exception: train: Error loading data from /content/datasets/images/training/im0.jpg: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
The training images I have (im0.jpg and im1.jpg) are two large files. The first has dimensions of 9058 x 11185, and the second file is 13385 x 12832. I realize they are not square but I'm assuming that the train.py module will make them square, so it's okay. Is that right?
Or could the non-square dimensions be causing the choke?
Also, what is the meaning of the exception "error loading data from /content/datasets/images/training/im0.jpg: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte"?
Thank you.
I've been using yolov5 for the past 1 month.I must say your error is wierd.
And also, you cant train your model with image size as 12000. By default it should be 640.In your case it might change based on your dataset but i'm quite sure that it wont be 12000.
There is a mistake in your data directory also.
--data /content/datasets/annotations/dataset.yaml.txt
The data file wont have '.txt' extension. It should be a '.yaml' file. SO change that to
--data /content/datasets/annotations/dataset.yaml
It should start training after these changes. If not, close this question and please provide additional information and ask another question.
the error
'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
is raised when you use a image of format which is not mentioned by default.
IMG_FORMATS = 'bmp', 'dng', 'jpeg', 'jpg', 'mpo', 'png', 'tif', 'tiff', 'webp' # include image suffixes
But you have mentioned that it is an jpg. I'm confused now. And also if it helps, pls try this solution provided in this issue. link
The Systemverilog code below is a single file testbench which reads a binary file into a memory using $fread then prints the memory contents. The binary file is 16 bytes and a view of it is included below (this is what I expect the Systemverilog code to print).
The output printed matches what I expect for the first 6 (0-5) bytes. At that point the expected output is 0x80, however the printed output is a sequence of 3 bytes starting with 0xef which are not in the stimulus file. After those 3 bytes the output matches the stimulus again. It seems as if when bit 7 of the binary byte read is 1, then the error occurs. It almost as if the data is being treated as signed, but it is not, its binary data printed as hex. The memory is defined as type logic which is unsigned.
This is similar to a question/answer in this post:
Read binary file data in Verilog into 2D Array.
However my code does not have the same issue (I use "rb") in the $fopen statement, so that
solution does not apply to this issue.
The Systemverilog spec 1800-2012 states in section 21.3.4.4 Reading binary data that $fread can be used to read a binary file and goes on to say how. I believe this example is compliant to what is stated in that section.
The code is posted on EDA Playground so that users can see it and run it.
https://www.edaplayground.com/x/5wzA
You need a login to run it and download. The login is free. It provides
access to full cloud-based versions of the industry standard tools for HDL simulation.
Also tried running 3 different simulators on EDA Playground. They all produce the same result.
Have tried re-arranging the stim.bin file so that the 0x80 value occurs at the beginning of the file rather than in the middle. In that case the error also occurs at the beginning of the testbench printing output.
Maybe the Systemverilog code is fine and the problem is the binary file? I have provided a screenshot of what emacs hexl mode shows for it's contents. Also viewed it another viewer and it looked the same. You can download it when running on EDA Playground to examine it in another editor. The binary file was generated by GNU Octave.
Would prefer to have a solution which uses Systemverilog $fread rather than something else in order to debug the original rather than work around it (learning). This will be developed into a Systemverilog testbench which applies stimulus read from a binary file generated in Octave/Matlab to a Systemverilog DUT. Binary fileIO is prefered because of the file access speed.
Why does the Systemverilog testbench print 0xef rather than 0x80 for mem[6]?
module tb();
// file descriptors
int read_file_descriptor;
// memory
logic [7:0] mem [15:0];
// ---------------------------------------------------------------------------
// Open the file
// ---------------------------------------------------------------------------
task open_file();
$display("Opening file");
read_file_descriptor=$fopen("stim.bin","rb");
endtask
// ---------------------------------------------------------------------------
// Read the contents of file descriptor
// ---------------------------------------------------------------------------
task readBinFile2Mem ();
int n_Temp;
n_Temp = $fread(mem, read_file_descriptor);
$display("n_Temp = %0d",n_Temp);
endtask
// ---------------------------------------------------------------------------
// Close the file
// ---------------------------------------------------------------------------
task close_file();
$display("Closing the file");
$fclose(read_file_descriptor);
endtask
// ---------------------------------------------------------------------------
// Shut down testbench
// ---------------------------------------------------------------------------
task shut_down();
$stop;
endtask
// ---------------------------------------------------------------------------
// Print memory contents
// ---------------------------------------------------------------------------
task printMem();
foreach(mem[i])
$display("mem[%0d] = %h",i,mem[i]);
endtask
// ---------------------------------------------------------------------------
// Main execution loop
// ---------------------------------------------------------------------------
initial
begin :initial_block
open_file;
readBinFile2Mem;
close_file;
printMem;
shut_down;
end :initial_block
endmodule
Binary Stimulus File:
Actual output:
Opening file
n_Temp = 16
Closing the file
mem[15] = 01
mem[14] = 00
mem[13] = 50
mem[12] = 60
mem[11] = 71
mem[10] = 72
mem[9] = 73
mem[8] = bd
mem[7] = bf
mem[6] = ef
mem[5] = 73
mem[4] = 72
mem[3] = 71
mem[2] = 60
mem[1] = 50
mem[0] = 00
Update:
An experiment was run in order to test that the binary file may be getting modified during the process of uploading to EDA playground. There is no Systemverilog code involved in these steps, it's just a file upload/download.
Steps:
(Used https://hexed.it/ to create and view the binary file)
Create/save binary file with the hex pattern 80 00 80 00 80 00 80 00
Create new playground
Upload new created binary file to the new playground
Check the 'download files after run' box on the playground
Save playground
Run playground
Save/unzip the results from the playground run
View the binary file, in my case it has been modified during the process of
upload/download. A screenshot of the result is shown below:
This experiment was conducted on two different Windows workstations.
Based on these results and the comments I am going to close this issue, with the disposition that this is not a Systemverilog issue, but is related to upload/dowload of binary files to EDA playground. Thanks to those who commented.
The unexpected output produced by the testbench is due to modifications that occur to the binary stimulus file during/after upload to EDA playground. The Systemverilog testbench performs as intended to print the contents of the binary file.
This conclusion is based on community comments and experimental results which are provided at the end of the updated question. A detailed procedure is given so that others can repeat the experiment.
I am trying to run ConnectedThresholdImageFilter example in ITK mentioned "https://itk.org/Doxygen45/html/Segmentation_2ConnectedThresholdImageFilter_8cxx-example.html" here.
But it is showing the following error.
itk::ImageFileWriterException (0x24cb740)
Location: "void itk::ImageFileWriter::Write() [with
TInputImage = itk::Image]" File:
/usr/local/include/ITK-4.13/itkImageFileWriter.hxx Line: 151
Description: Could not create IO object for writing file output
Tried to create one of the following:
BMPImageIO
BioRadImageIO
Bruker2dseqImageIO
GDCMImageIO
GE4ImageIO
GE5ImageIO
GiplImageIO
HDF5ImageIO
JPEGImageIO
LSMImageIO
MINCImageIO
MRCImageIO
MetaImageIO
NiftiImageIO
NrrdImageIO
PNGImageIO
StimulateImageIO
TIFFImageIO
VTKImageIO You probably failed to set a file suffix, or
set the suffix to an unsupported type
I didn't do any changes in code. And I am trying to use dicom image as an input.
It is either
You set the output file name with an unsupported extension.
There is something wrong about how you compiled/linked ITK or how you are linking your example to ITK.
I have a problem with upload files to wordpress system.
If i tried to upload a test.jpg file with size of arround 80 KB, than i get the follow error:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8388616 bytes) in /var/www/vhosts/*****/httpdocs/wp-includes/wp-db.php on line 1890
I have tried to put follow code in wp-config.php
define( 'WP_MAX_MEMORY_LIMIT' , '512M' );
But without success.
On the server log after uploaded the test file I get this error:
AH01071: Got error 'PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vhosts/*****/httpdocs/wp-includes/wp-db.php on line 1889\n', referer: https://*********/wp-admin/media-new.php
Now i have put an other backup so I got an other error:
WordPress databasefout: [Duplicate entry '0' for key 'PRIMARY']
INSERT INTO `x9i8Z_icl_translations` (`element_type`, `language_code`, `trid`) VALUES ('post_attachment', 'nl', '7526')
Notice: Trying to get property of non-object in /var/www/vhosts/***********/httpdocs/wp-content/plugins/sitepress-multilingual-cms/classes/media/duplication/class-wpml-media-attachments-duplication.php on line 201
Notice: Trying to get property of non-object in /var/www/vhosts/***********/httpdocs/wp-content/plugins/sitepress-multilingual-cms/classes/media/duplication/class-wpml-media-attachments-duplication.php on line 201
0
Its strange because on the old version it works good, but if i put all the database data on a new schema it doesnt work any more :(
You need to setup upload_max_size via wp-config.php file.
#ini_set( 'upload_max_size' , '512M' );
It is better to increase the max execution time with the upload size. So, your final output will look like this.
#ini_set( 'upload_max_size' , '512M' );
#ini_set( 'post_max_size', '512M');
#ini_set( 'max_execution_time', '2400' );
I'm unable to understand why there occurs character decoding failed warning at my server.
May 19, 2012 2:56:57 AM org.apache.tomcat.util.http.Parameters processParameters
WARNING: Parameters: Character decoding failed. Parameter 'width' with value '100%' has been ignored. Note that the name and value quoted here may corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
Well, the % at the end signifies a bad encoding. If properly encoded, it should really be followed by two hexadecimal characters.
if 'Parameters: Character decoding failed' warning include % issue then we can use given below
code, no need to do any thing. I am using this in my ajax function.
var productPromoCodeIdParam = productPromoCodeId.replace('%','%25');