本文整理汇总了Java中javax.sound.midi.spi.MidiFileWriter类的典型用法代码示例。如果您正苦于以下问题:Java MidiFileWriter类的具体用法?Java MidiFileWriter怎么用?Java MidiFileWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MidiFileWriter类属于javax.sound.midi.spi包,在下文中一共展示了MidiFileWriter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProviders
import javax.sound.midi.spi.MidiFileWriter; //导入依赖的package包/类
/**
* Obtains a List containing installed instances of the providers for the
* requested service. The returned List is immutable.
*
* @param serviceClass The type of providers requested. This should be one
* of AudioFileReader.class, AudioFileWriter.class,
* FormatConversionProvider.class, MixerProvider.class,
* MidiDeviceProvider.class, MidiFileReader.class,
* MidiFileWriter.class or SoundbankReader.class.
*
* @return A List of providers of the requested type. This List is
* immutable.
*/
public static List<?> getProviders(final Class<?> serviceClass) {
final List<?> providers;
if (!MixerProvider.class.equals(serviceClass)
&& !FormatConversionProvider.class.equals(serviceClass)
&& !AudioFileReader.class.equals(serviceClass)
&& !AudioFileWriter.class.equals(serviceClass)
&& !MidiDeviceProvider.class.equals(serviceClass)
&& !SoundbankReader.class.equals(serviceClass)
&& !MidiFileWriter.class.equals(serviceClass)
&& !MidiFileReader.class.equals(serviceClass)) {
providers = new ArrayList<>(0);
} else {
providers = JSSecurityManager.getProviders(serviceClass);
}
return Collections.unmodifiableList(providers);
}
示例2: getMidiFileTypes
import javax.sound.midi.spi.MidiFileWriter; //导入依赖的package包/类
/**
* Obtains the set of MIDI file types for which file writing support is
* provided by the system.
* @return array of unique file types. If no file types are supported,
* an array of length 0 is returned.
*/
public static int[] getMidiFileTypes() {
List providers = getMidiFileWriters();
Set allTypes = new HashSet();
// gather from all the providers
for (int i = 0; i < providers.size(); i++ ) {
MidiFileWriter writer = (MidiFileWriter) providers.get(i);
int[] types = writer.getMidiFileTypes();
for (int j = 0; j < types.length; j++ ) {
allTypes.add(new Integer(types[j]));
}
}
int resultTypes[] = new int[allTypes.size()];
int index = 0;
Iterator iterator = allTypes.iterator();
while (iterator.hasNext()) {
Integer integer = (Integer) iterator.next();
resultTypes[index++] = integer.intValue();
}
return resultTypes;
}
示例3: write
import javax.sound.midi.spi.MidiFileWriter; //导入依赖的package包/类
/**
* Writes a stream of bytes representing a file of the MIDI file type
* indicated to the output stream provided.
* @param in sequence containing MIDI data to be written to the file
* @param fileType the file type of the file to be written to the output stream
* @param out stream to which the file data should be written
* @return the number of bytes written to the output stream
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file format is not supported by
* the system
* @see #isFileTypeSupported(int, Sequence)
* @see #getMidiFileTypes(Sequence)
*/
public static int write(Sequence in, int fileType, OutputStream out) throws IOException {
List providers = getMidiFileWriters();
//$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
int bytesWritten = -2;
for (int i = 0; i < providers.size(); i++ ) {
MidiFileWriter writer = (MidiFileWriter) providers.get(i);
if( writer.isFileTypeSupported( fileType, in ) ) {
bytesWritten = writer.write(in, fileType, out);
break;
}
}
if (bytesWritten == -2) {
throw new IllegalArgumentException("MIDI file type is not supported");
}
return bytesWritten;
}
示例4: getMidiFileTypes
import javax.sound.midi.spi.MidiFileWriter; //导入依赖的package包/类
/**
* Obtains the set of MIDI file types for which file writing support is
* provided by the system.
*
* @return array of unique file types. If no file types are supported, an
* array of length 0 is returned.
*/
public static int[] getMidiFileTypes() {
List<MidiFileWriter> providers = getMidiFileWriters();
Set<Integer> allTypes = new HashSet<>();
// gather from all the providers
for (int i = 0; i < providers.size(); i++ ) {
MidiFileWriter writer = providers.get(i);
int[] types = writer.getMidiFileTypes();
for (int j = 0; j < types.length; j++ ) {
allTypes.add(types[j]);
}
}
int resultTypes[] = new int[allTypes.size()];
int index = 0;
Iterator<Integer> iterator = allTypes.iterator();
while (iterator.hasNext()) {
Integer integer = iterator.next();
resultTypes[index++] = integer.intValue();
}
return resultTypes;
}
示例5: write
import javax.sound.midi.spi.MidiFileWriter; //导入依赖的package包/类
/**
* Writes a stream of bytes representing a file of the MIDI file type
* indicated to the output stream provided.
*
* @param in sequence containing MIDI data to be written to the file
* @param fileType the file type of the file to be written to the output
* stream
* @param out stream to which the file data should be written
* @return the number of bytes written to the output stream
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file format is not supported by
* the system
* @throws NullPointerException if {@code in} or {@code out} are
* {@code null}
* @see #isFileTypeSupported(int, Sequence)
* @see #getMidiFileTypes(Sequence)
*/
public static int write(final Sequence in, final int fileType,
final OutputStream out) throws IOException {
Objects.requireNonNull(in);
Objects.requireNonNull(out);
List<MidiFileWriter> providers = getMidiFileWriters();
//$$fb 2002-04-17: Fix for 4635287: Standard MidiFileWriter cannot write empty Sequences
int bytesWritten = -2;
for (int i = 0; i < providers.size(); i++ ) {
MidiFileWriter writer = providers.get(i);
if( writer.isFileTypeSupported( fileType, in ) ) {
bytesWritten = writer.write(in, fileType, out);
break;
}
}
if (bytesWritten == -2) {
throw new IllegalArgumentException("MIDI file type is not supported");
}
return bytesWritten;
}