Mercurial > audlegacy-plugins
comparison src/amidi-plug/amidi-plug.c @ 240:59d793da5395 trunk
[svn] - import amidi-plug 0.7 (among new features, a transposer to play midi files in different keys)
author | giacomo |
---|---|
date | Mon, 13 Nov 2006 04:51:30 -0800 |
parents | 3da1b8942b8b |
children | cfd1b8a88e2d |
comparison
equal
deleted
inserted
replaced
239:e45005422574 | 240:59d793da5395 |
---|---|
32 { | 32 { |
33 #if defined(MIDIFILE_PROBE_MAGICBYTES) | 33 #if defined(MIDIFILE_PROBE_MAGICBYTES) |
34 VFSFile * fp; | 34 VFSFile * fp; |
35 gchar magic_bytes[4]; | 35 gchar magic_bytes[4]; |
36 | 36 |
37 fp = vfs_fopen( filename , "rb" ); | 37 fp = VFS_FOPEN( filename , "rb" ); |
38 | 38 |
39 if ( fp == NULL ) | 39 if ( fp == NULL ) |
40 return FALSE; | 40 return FALSE; |
41 | 41 |
42 vfs_fread( magic_bytes , 1 , 4 , fp ); | 42 VFS_FREAD( magic_bytes , 1 , 4 , fp ); |
43 | 43 |
44 if ( !strncmp( magic_bytes , "MThd" , 4 ) ) | 44 if ( !strncmp( magic_bytes , "MThd" , 4 ) ) |
45 { | 45 { |
46 vfs_fclose( fp ); | 46 VFS_FCLOSE( fp ); |
47 DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename ); | 47 DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename ); |
48 return TRUE; | 48 return TRUE; |
49 } | 49 } |
50 | 50 |
51 if ( !strncmp( magic_bytes , "RIFF" , 4 ) ) | 51 if ( !strncmp( magic_bytes , "RIFF" , 4 ) ) |
52 { | 52 { |
53 /* skip the four bytes after RIFF, | 53 /* skip the four bytes after RIFF, |
54 then read the next four */ | 54 then read the next four */ |
55 vfs_fseek( fp , 4 , SEEK_CUR ); | 55 VFS_FSEEK( fp , 4 , SEEK_CUR ); |
56 vfs_fread( magic_bytes , 1 , 4 , fp ); | 56 VFS_FREAD( magic_bytes , 1 , 4 , fp ); |
57 if ( !strncmp( magic_bytes , "RMID" , 4 ) ) | 57 if ( !strncmp( magic_bytes , "RMID" , 4 ) ) |
58 { | 58 { |
59 vfs_fclose( fp ); | 59 VFS_FCLOSE( fp ); |
60 DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename ); | 60 DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename ); |
61 return TRUE; | 61 return TRUE; |
62 } | 62 } |
63 } | 63 } |
64 vfs_fclose( fp ); | 64 VFS_FCLOSE( fp ); |
65 #else | 65 #else |
66 gchar * ext = strrchr( filename, '.' ); | 66 gchar * ext = strrchr( filename, '.' ); |
67 /* check the filename extension */ | 67 /* check the filename extension */ |
68 if ( ( ext ) && | 68 if ( ( ext ) && |
69 (( !strcasecmp(ext,".mid") ) || ( !strcasecmp(ext,".midi") ) || | 69 (( !strcasecmp(ext,".mid") ) || ( !strcasecmp(ext,".midi") ) || |
389 amidiplug_playing_status = AMIDIPLUG_ERR; | 389 amidiplug_playing_status = AMIDIPLUG_ERR; |
390 return; | 390 return; |
391 } | 391 } |
392 | 392 |
393 DEBUGMSG( "PLAY requested, opening file: %s\n" , filename ); | 393 DEBUGMSG( "PLAY requested, opening file: %s\n" , filename ); |
394 midifile.file_pointer = vfs_fopen( filename , "rb" ); | 394 midifile.file_pointer = VFS_FOPEN( filename , "rb" ); |
395 if (!midifile.file_pointer) | 395 if (!midifile.file_pointer) |
396 { | 396 { |
397 g_warning( "Cannot open %s\n" , filename ); | 397 g_warning( "Cannot open %s\n" , filename ); |
398 amidiplug_playing_status = AMIDIPLUG_ERR; | 398 amidiplug_playing_status = AMIDIPLUG_ERR; |
399 return; | 399 return; |
467 g_warning( "%s is not a Standard MIDI File\n" , filename ); | 467 g_warning( "%s is not a Standard MIDI File\n" , filename ); |
468 break; | 468 break; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 vfs_fclose( midifile.file_pointer ); | 472 VFS_FCLOSE( midifile.file_pointer ); |
473 return; | 473 return; |
474 } | 474 } |
475 | 475 |
476 | 476 |
477 | 477 |